From f5037353d9e810d2a8385245f7195e9edf8221b1 Mon Sep 17 00:00:00 2001 From: yang <2119157836@qq.com> Date: Thu, 6 Mar 2025 17:30:27 +0800 Subject: [PATCH 1/7] =?UTF-8?q?feat(memberCenter):=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mcwl-admin/src/main/resources/application-dev.yml | 3 ++- mcwl-admin/src/main/resources/application-druid.yml | 7 ++++--- .../main/java/com/mcwl/framework/config/RedisConfig.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mcwl-admin/src/main/resources/application-dev.yml b/mcwl-admin/src/main/resources/application-dev.yml index c7c18bb..822d33a 100644 --- a/mcwl-admin/src/main/resources/application-dev.yml +++ b/mcwl-admin/src/main/resources/application-dev.yml @@ -97,7 +97,8 @@ spring: # 连接池的最大数据库连接数 max-active: 1000 # #连接池最大阻塞等待时间(使用负值表示没有限制) - max-wait: -1ms # 默认使用的数据库索引 + max-wait: -1ms + time-between-eviction-runs: 6000 #ai配置 ai: dashscope: diff --git a/mcwl-admin/src/main/resources/application-druid.yml b/mcwl-admin/src/main/resources/application-druid.yml index a007af4..25d6c6b 100644 --- a/mcwl-admin/src/main/resources/application-druid.yml +++ b/mcwl-admin/src/main/resources/application-druid.yml @@ -91,13 +91,14 @@ spring: lettuce: pool: # 连接池中的最小空闲连接 - min-idle: 0 + min-idle: 5 # 连接池中的最大空闲连接 - max-idle: 8 + max-idle: 10 # 连接池的最大数据库连接数 - max-active: 8 + max-active: 1000 # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms + time-between-eviction-runs: 6000 # token配置 diff --git a/mcwl-framework/src/main/java/com/mcwl/framework/config/RedisConfig.java b/mcwl-framework/src/main/java/com/mcwl/framework/config/RedisConfig.java index f26dc5f..2eb4907 100644 --- a/mcwl-framework/src/main/java/com/mcwl/framework/config/RedisConfig.java +++ b/mcwl-framework/src/main/java/com/mcwl/framework/config/RedisConfig.java @@ -79,7 +79,7 @@ public class RedisConfig extends CachingConfigurerSupport * @return RedisConnectionFactory */ @Bean - public RedisConnectionFactory redisConnectionFactory() { + public LettuceConnectionFactory redisConnectionFactory() { RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration("1.13.246.108", 6370); standaloneConfig.setPassword(RedisPassword.of("MuYu_Cloud@Redis")); From ff6b2cdf30f7bb09dad25ed6c6534181447ffd7b Mon Sep 17 00:00:00 2001 From: yang <2119157836@qq.com> Date: Fri, 7 Mar 2025 10:56:47 +0800 Subject: [PATCH 2/7] =?UTF-8?q?refactor(mcwl):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=BF=83=E9=94=80=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../memberCenter/PromotionController.java | 97 ++------- .../memberCenter/domain/vo/PromotionVo.java | 63 ++++++ .../service/PromotionService.java | 16 ++ .../service/impl/PromotionServiceImpl.java | 193 ++++++++++++++++++ .../memberCenter/task/UserMemberTask.java | 8 + 5 files changed, 298 insertions(+), 79 deletions(-) create mode 100644 mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/domain/vo/PromotionVo.java diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/PromotionController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/PromotionController.java index 90e14bc..fcacbfc 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/PromotionController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/PromotionController.java @@ -4,6 +4,8 @@ package com.mcwl.web.controller.memberCenter; import cn.hutool.core.bean.BeanUtil; import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.R; +import com.mcwl.common.core.page.PageDomain; +import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.utils.SecurityUtils; import com.mcwl.memberCenter.domain.Member; import com.mcwl.memberCenter.domain.MemberPromotion; @@ -17,10 +19,12 @@ import com.mcwl.memberCenter.service.MemberService; import com.mcwl.memberCenter.service.PromotionService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import javax.validation.constraints.NotNull; import java.util.Date; import java.util.List; import java.util.Optional; @@ -39,8 +43,6 @@ public class PromotionController { private final MemberPromotionService memberPromotionService; - private final MemberService memberService; - /** * 创建活动 @@ -67,76 +69,34 @@ public class PromotionController { /** * 活动列表 */ - @GetMapping("promotionList") + @PostMapping("promotionList") @ApiOperation(value = "活动列表") - public R> promotionList() { - List promotionList = promotionService.lambdaQuery() - .gt(Promotion::getEndTime, new Date()) - .list(); - return R.ok(promotionList); + public TableDataInfo getPromotionList(@Valid @RequestBody PageDomain pageDomain) { + + return promotionService.getPromotionList(pageDomain); } /** * 获取当前用户参与的活动 */ - @GetMapping("myPromotionList") + @PostMapping("myPromotionList") @ApiOperation(value = "获取当前用户参与的活动") - public R> myPromotionList() { - // 获取当前用户 - Long userId = SecurityUtils.getUserId(); - List memberPromotionList = memberPromotionService.lambdaQuery() - .eq(MemberPromotion::getUserId, userId) - .list(); - return R.ok(memberPromotionList); + public TableDataInfo myPromotionList(@Valid @RequestBody PageDomain pageDomain) { + + return promotionService.getMyPromotionList(pageDomain); } /** * 参与活动 */ - @PostMapping("joinPromotion") + @GetMapping("joinPromotion") @ApiOperation(value = "参与活动") - public R joinPromotion(@RequestBody @Valid JoinPromotionDto joinPromotionDto) { - // 用户id - Long userId = joinPromotionDto.getUserId(); - // 活动id - Long promotionId = joinPromotionDto.getPromotionId(); - // 按活动id查询活动信息 - Promotion promotion = promotionService.getById(promotionId); + public R joinPromotion(@Valid + @NotNull(message = "活动ID不能为空") + @ApiParam("活动ID") + Long promotionId) { - if (!Optional.ofNullable(promotion).isPresent()) { - return R.fail("活动不存在"); - } - - if (promotion.getStartTime().after(new Date())) { - return R.fail("活动未开始"); - } - - // 活动是否过期 - if (promotion.getEndTime().before(new Date())) { - return R.fail("活动已过期"); - } - - // 获取当前用户是否参与过该活动 - if (isJoinPromotion(userId, promotionId)) { - return R.fail("您已参与过该活动"); - } - - // 是否在活动期间内订阅或续订会员 -// if (!isSubscribe(userId, promotion)) { -// return AjaxResult.warn("请在活动期间内订阅或续期会员后参加该活动"); -// } - - Member member = memberService.getUseUserMemberByUserId(userId); - - String memberLevelIds = promotion.getMemberLevelIds(); - if (!memberLevelIds.contains(member.getMemberLevelId().toString())) { - return R.fail("无法参与该活动,请查看活动条件"); - } - MemberPromotion memberPromotion = getMemberPromotion(userId, promotionId); - memberPromotionService.save(memberPromotion); - - - return R.ok(); + return promotionService.joinPromotion(promotionId); } // private boolean isSubscribe(Long userId, Promotion promotion) { @@ -153,26 +113,5 @@ public class PromotionController { // 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; - } - } diff --git a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/domain/vo/PromotionVo.java b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/domain/vo/PromotionVo.java new file mode 100644 index 0000000..7aa368c --- /dev/null +++ b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/domain/vo/PromotionVo.java @@ -0,0 +1,63 @@ +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 com.mcwl.memberCenter.enums.PromotionEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 促销活动vo + */ +@Data +@ApiModel(description = "促销活动") +public class PromotionVo { + + /** + * 活动id + */ + @ApiModelProperty(value = "活动id") + private Long id; + + /** + * 活动名称 + */ + @ApiModelProperty(value = "活动名称") + private String activityName; + + /** + * 是否参与 + */ + @ApiModelProperty(value = "是否参与") + private Integer isJoin; + + + /** + * 活动的详细描述 + */ + @ApiModelProperty(value = "活动的详细描述") + private String description; + + /** + * 活动开始时间 + */ + @ApiModelProperty(value = "活动开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date startTime; + + /** + * 活动结束时间 + */ + @ApiModelProperty(value = "活动结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endTime; + + + +} diff --git a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/PromotionService.java b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/PromotionService.java index 39e313b..fabd0c2 100644 --- a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/PromotionService.java +++ b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/PromotionService.java @@ -1,8 +1,24 @@ package com.mcwl.memberCenter.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.mcwl.common.core.domain.R; +import com.mcwl.common.core.page.PageDomain; +import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.memberCenter.domain.MemberPromotion; import com.mcwl.memberCenter.domain.Promotion; +import java.util.List; + public interface PromotionService extends IService { + + /** + * 获取促销活动列表 + * @return TableDataInfo + */ + TableDataInfo getPromotionList(PageDomain pageDomain); + + + TableDataInfo getMyPromotionList(PageDomain pageDomain); + + R joinPromotion(Long promotionId); } diff --git a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/impl/PromotionServiceImpl.java b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/impl/PromotionServiceImpl.java index 25364c1..4ff9f38 100644 --- a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/impl/PromotionServiceImpl.java +++ b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/impl/PromotionServiceImpl.java @@ -1,17 +1,210 @@ package com.mcwl.memberCenter.service.impl; +import cn.hutool.core.bean.BeanUtil; +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.mcwl.common.constant.HttpStatus; +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.memberCenter.domain.Member; import com.mcwl.memberCenter.domain.MemberPromotion; import com.mcwl.memberCenter.domain.Promotion; +import com.mcwl.memberCenter.domain.vo.PromotionVo; +import com.mcwl.memberCenter.enums.PromotionEnum; import com.mcwl.memberCenter.mapper.MemberPromotionMapper; import com.mcwl.memberCenter.mapper.PromotionMapper; import com.mcwl.memberCenter.service.MemberPromotionService; +import com.mcwl.memberCenter.service.MemberService; import com.mcwl.memberCenter.service.PromotionService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.*; + @Service @RequiredArgsConstructor public class PromotionServiceImpl extends ServiceImpl implements PromotionService { + private final MemberPromotionService memberPromotionService; + + private final MemberService memberService; + + /** + * 获取促销活动列表 + * + * @return TableDataInfo + */ + @Override + public TableDataInfo getPromotionList(PageDomain pageDomain) { + + // 封装用户参加的促销活动, key为促销活动id, value为用户参加的促销活动 + Map map = new HashMap<>(); + + // 获取用户参加的促销活动 + Long userId = SecurityUtils.getUserId(); + List memberPromotionList = memberPromotionService.lambdaQuery() + .eq(MemberPromotion::getUserId, userId) + .eq(MemberPromotion::getStatus, PromotionEnum.PARTICIPATE) + .list(); + for (MemberPromotion memberPromotion : memberPromotionList) { + map.put(memberPromotion.getPromotionId(), memberPromotion); + } + + // 查询促销活动列表 + Page page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); + + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.gt(Promotion::getEndTime, new Date()); + + baseMapper.selectPage(page, lqw); + + // 封装数据 + List promotionVoList = new ArrayList<>(); + page.getRecords().forEach(promotion -> { + PromotionVo promotionVo = new PromotionVo(); + BeanUtil.copyProperties(promotion, promotionVo); + if (map.containsKey(promotion.getId())) { + promotionVo.setIsJoin(1); + } else { + promotionVo.setIsJoin(0); + } + promotionVoList.add(promotionVo); + }); + + // 封装分页结果 + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(promotionVoList); + rspData.setTotal(page.getTotal()); + + return rspData; + } + + /** + * 获取用户参加的促销活动 + * + * @param pageDomain 分页参数 + * @return TableDataInfo + */ + @Override + public TableDataInfo getMyPromotionList(PageDomain pageDomain) { + + // 获取当前用户 + Long userId = SecurityUtils.getUserId(); + + + List memberPromotionIds = new ArrayList<>(); + // 默认添加一个不存在的id, 防止List为空时in查询出错 + memberPromotionIds.add(-1L); + + // 查询用户参加的促销活动 + List memberPromotionList = memberPromotionService.lambdaQuery() + .eq(MemberPromotion::getUserId, userId) + .eq(MemberPromotion::getStatus, PromotionEnum.PARTICIPATE) + .list(); + for (MemberPromotion memberPromotion : memberPromotionList) { + memberPromotionIds.add(memberPromotion.getPromotionId()); + } + + // 查询促销活动列表 + Page page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); + + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.in(Promotion::getId, memberPromotionIds); + baseMapper.selectPage(page, lqw); + + // 封装数据 + List promotionVoList = new ArrayList<>(); + page.getRecords().forEach(promotion -> { + PromotionVo promotionVo = new PromotionVo(); + BeanUtil.copyProperties(promotion, promotionVo); + promotionVoList.add(promotionVo); + }); + + + // 封装分页结果 + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(promotionVoList); + rspData.setTotal(page.getTotal()); + + return rspData; + } + + + /** + * 用户参加促销活动 + * + * @param promotionId 促销活动id + * @return R + */ + @Override + public R joinPromotion(Long promotionId) { + + // 用户id + Long userId = SecurityUtils.getUserId(); + + // 按活动id查询活动信息 + Promotion promotion = baseMapper.selectById(promotionId); + + if (!Optional.ofNullable(promotion).isPresent()) { + return R.fail("活动不存在"); + } + + if (promotion.getStartTime().after(new Date())) { + return R.fail("活动未开始"); + } + + // 活动是否过期 + if (promotion.getEndTime().before(new Date())) { + return R.fail("活动已过期"); + } + + // 获取当前用户是否参与过该活动 + if (isJoinPromotion(userId, promotionId)) { + return R.fail("您已参与过该活动"); + } + + // 是否在活动期间内订阅或续订会员 +// if (!isSubscribe(userId, promotion)) { +// return AjaxResult.warn("请在活动期间内订阅或续期会员后参加该活动"); +// } + + Member member = memberService.getUseUserMemberByUserId(userId); + String memberLevelId = Objects.isNull(member) ? "-1" : member.getMemberLevelId().toString(); + + String memberLevelIds = promotion.getMemberLevelIds(); + if (!memberLevelIds.contains(memberLevelId)) { + return R.fail("会员等级不够,无法参与该活动,请查看活动条件"); + } + MemberPromotion memberPromotion = getMemberPromotion(userId, promotionId); + memberPromotionService.save(memberPromotion); + + return R.ok(); + } + + + 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()); + return memberPromotion; + } + + } diff --git a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java index 7d38aaa..cdf8b64 100644 --- a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java +++ b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java @@ -129,6 +129,14 @@ public class UserMemberTask { } + /** + * 会员参与的促销活动是否过期 每天晚上0点检查 0 0 0 * * ? + */ + public void checkPromotionExpiredTask() { + + } + + /** * 根据会员等级获取积分 */ From 535b175fabaaffd64d0649e6f7785af414850a78 Mon Sep 17 00:00:00 2001 From: yang <2119157836@qq.com> Date: Fri, 7 Mar 2025 13:19:56 +0800 Subject: [PATCH 3/7] =?UTF-8?q?feat(myInvitation):=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myInvitation/InvitationController.java | 32 ++++++++++++++++--- .../service/impl/PromotionServiceImpl.java | 10 +++--- .../memberCenter/task/UserMemberTask.java | 23 ++++++++----- .../mcwl/myInvitation/domain/Commission.java | 7 ++-- .../service/impl/ConsumeServiceImpl.java | 3 +- .../mapper/myInvitation/InvitationMapper.xml | 9 ++---- .../pay/service/impl/AliPayServiceImpl.java | 1 + .../service/impl/OrderTradeServiceImpl.java | 2 +- .../service/ISysUserPayAccountLogService.java | 10 ++++++ .../impl/SysUserPayAccountLogServiceImpl.java | 27 ++++++++++++++++ 10 files changed, 93 insertions(+), 31 deletions(-) diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java index 82d58a6..9c4dffc 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java @@ -3,20 +3,20 @@ package com.mcwl.web.controller.myInvitation; import com.mcwl.common.core.domain.AjaxResult; 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.myInvitation.domain.Invitation; import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto; import com.mcwl.myInvitation.service.InvitationService; import com.mcwl.myInvitation.domain.vo.EarningsDisplayVO; +import com.mcwl.system.service.ISysUserPayAccountLogService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; -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.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import javax.validation.constraints.NotNull; @@ -39,6 +39,8 @@ public class InvitationController { private final InvitationService invitationService; + private final ISysUserPayAccountLogService sysUserPayAccountLogService; + /** * 获取邀请码 @@ -103,4 +105,26 @@ public class InvitationController { } + /** + * 累计收入金额 + */ + @GetMapping("totalAmount") + @ApiOperation(value = "累计收入金额") + public R 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); + } + + } diff --git a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/impl/PromotionServiceImpl.java b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/impl/PromotionServiceImpl.java index 4ff9f38..41e8f71 100644 --- a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/impl/PromotionServiceImpl.java +++ b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/service/impl/PromotionServiceImpl.java @@ -153,21 +153,21 @@ public class PromotionServiceImpl extends ServiceImpl promotionIdList = new ArrayList<>(); + List promotionList = promotionService.lambdaQuery() + .lt(Promotion::getEndTime, new Date()) // 活动结束日期小于当前时间 + .list(); + for (Promotion promotion : promotionList) { + promotionIdList.add(promotion.getId()); + } + } diff --git a/mcwl-myInvitation/src/main/java/com/mcwl/myInvitation/domain/Commission.java b/mcwl-myInvitation/src/main/java/com/mcwl/myInvitation/domain/Commission.java index 97c2202..3543c6e 100644 --- a/mcwl-myInvitation/src/main/java/com/mcwl/myInvitation/domain/Commission.java +++ b/mcwl-myInvitation/src/main/java/com/mcwl/myInvitation/domain/Commission.java @@ -19,12 +19,9 @@ public class Commission extends BaseEntity { @TableId private Long id; - // 消费者id - private Long consumeId; + // 用户id + private Long userId; // 提成金额 private Double amount; - - // 支付状态 - private Integer payStatus; } diff --git a/mcwl-myInvitation/src/main/java/com/mcwl/myInvitation/service/impl/ConsumeServiceImpl.java b/mcwl-myInvitation/src/main/java/com/mcwl/myInvitation/service/impl/ConsumeServiceImpl.java index 53c2c8b..d30f77d 100644 --- a/mcwl-myInvitation/src/main/java/com/mcwl/myInvitation/service/impl/ConsumeServiceImpl.java +++ b/mcwl-myInvitation/src/main/java/com/mcwl/myInvitation/service/impl/ConsumeServiceImpl.java @@ -45,11 +45,10 @@ public class ConsumeServiceImpl extends ServiceImpl impl // commission.setUserId(sysUser.getParentId()); // 设置消费者id - commission.setConsumeId(consume.getUserId()); + commission.setUserId(consume.getUserId()); // TODO 设置佣金,目前固定2.0 commission.setAmount(2.0); - commission.setPayStatus(0); commissionService.save(commission); diff --git a/mcwl-myInvitation/src/main/resources/mapper/myInvitation/InvitationMapper.xml b/mcwl-myInvitation/src/main/resources/mapper/myInvitation/InvitationMapper.xml index c6daf41..ce3883c 100644 --- a/mcwl-myInvitation/src/main/resources/mapper/myInvitation/InvitationMapper.xml +++ b/mcwl-myInvitation/src/main/resources/mapper/myInvitation/InvitationMapper.xml @@ -6,12 +6,9 @@ + + diff --git a/mcwl-resource/src/main/resources/mapper/resource/DownloadRecordMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/DownloadRecordMapper.xml new file mode 100644 index 0000000..362f921 --- /dev/null +++ b/mcwl-resource/src/main/resources/mapper/resource/DownloadRecordMapper.xml @@ -0,0 +1,14 @@ + + + + + + + UPDATE download_record + SET file_size = #{fileSize}, + status = #{status} + WHERE id = #{id} + + diff --git a/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml index 9f1db12..cb82366 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/ModelMapper.xml @@ -93,6 +93,7 @@ LEFT JOIN sys_user as u on m.user_id = u.user_id WHERE m.del_flag = 0 + and audit_status = 1 and m.model_name like CONCAT('%', #{name}, '%') diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java index 4331292..9892e3e 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserServiceImpl.java @@ -612,9 +612,10 @@ public class SysUserServiceImpl implements ISysUserService @Override public SysUser selectUserInfoById(Long userId) { SysUser sysUser = userMapper.selectUserInfoById(userId); - - SysUser sysUser1 = selectUserById(sysUser.getInviterUserId()); - sysUser.setInvitationName(sysUser1.getNickName()); + if (sysUser.getInviterUserId() != null){ + SysUser sysUser1 = selectUserById(sysUser.getInviterUserId()); + sysUser.setInvitationName(sysUser1.getNickName()); + } return sysUser; } From 489db2410d83a26ef4ec7bfa9ea57a2536a99c40 Mon Sep 17 00:00:00 2001 From: yang <2119157836@qq.com> Date: Fri, 7 Mar 2025 13:51:04 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat(myInvitation):=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../communityCenter/ChatController.java | 60 +++---- .../myInvitation/InvitationController.java | 8 +- mcwl-communityCenter/pom.xml | 20 +-- .../config/WebSocketConfig.java | 64 +++---- .../service/impl/AIServiceImpl.java | 168 +++++++++--------- .../webSocket/ChatWebSocket.java | 164 ++++++++--------- .../webSocket/HumanWebSocket.java | 110 ++++++------ .../memberCenter/task/UserMemberTask.java | 38 +++- 8 files changed, 328 insertions(+), 304 deletions(-) diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/ChatController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/ChatController.java index ee0f2de..c07ef25 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/ChatController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/communityCenter/ChatController.java @@ -1,30 +1,30 @@ -package com.mcwl.web.controller.communityCenter; - - -import com.mcwl.communityCenter.service.AIService; -import com.mcwl.communityCenter.webSocket.ChatWebSocket; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Flux; - -@RequiredArgsConstructor -@RestController -@RequestMapping("/chat") -public class ChatController { - - private final AIService aiService; - - - /** - * ai - */ - @GetMapping("/ai") - public Flux switchUserMode(String msg) throws Exception { - return aiService.getDeepSeekResponseStream(msg); - } - - - -} +//package com.mcwl.web.controller.communityCenter; +// +// +//import com.mcwl.communityCenter.service.AIService; +//import com.mcwl.communityCenter.webSocket.ChatWebSocket; +//import lombok.RequiredArgsConstructor; +//import org.springframework.web.bind.annotation.GetMapping; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RestController; +//import reactor.core.publisher.Flux; +// +//@RequiredArgsConstructor +//@RestController +//@RequestMapping("/chat") +//public class ChatController { +// +// private final AIService aiService; +// +// +// /** +// * ai +// */ +// @GetMapping("/ai") +// public Flux switchUserMode(String msg) throws Exception { +// return aiService.getDeepSeekResponseStream(msg); +// } +// +// +// +//} diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java index 9c4dffc..d887e6e 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java @@ -20,10 +20,7 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; +import java.util.*; import static com.mcwl.common.core.domain.AjaxResult.success; @@ -113,6 +110,9 @@ public class InvitationController { public R totalAmount() { Long userId = SecurityUtils.getUserId(); Double totalAmount = invitationService.getTotalAmount(userId); + if (Objects.isNull(totalAmount)) { + totalAmount = 0.0; + } return R.ok(totalAmount); } diff --git a/mcwl-communityCenter/pom.xml b/mcwl-communityCenter/pom.xml index 9a80243..7561cc4 100644 --- a/mcwl-communityCenter/pom.xml +++ b/mcwl-communityCenter/pom.xml @@ -38,17 +38,17 @@ - - com.alibaba.cloud.ai - spring-ai-alibaba-starter - 1.0.0-M5.1 - + + + + + - - io.projectreactor.netty - reactor-netty-http - 1.1.6 - + + + + + diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/config/WebSocketConfig.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/config/WebSocketConfig.java index 789bf1f..0c27bb8 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/config/WebSocketConfig.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/config/WebSocketConfig.java @@ -1,32 +1,32 @@ -package com.mcwl.communityCenter.config; - -import com.mcwl.communityCenter.webSocket.ChatWebSocket; -import com.mcwl.communityCenter.webSocket.HumanWebSocket; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.config.annotation.EnableWebSocket; -import org.springframework.web.socket.config.annotation.WebSocketConfigurer; -import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; - -@Configuration -@EnableWebSocket -public class WebSocketConfig implements WebSocketConfigurer { - - @Override - public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { - registry.addHandler(chatWebSocket(), "/chat") - .addHandler(humanWebSocket(), "/chat/human") - .setAllowedOrigins("*"); - } - - @Bean - public ChatWebSocket chatWebSocket() { - return new ChatWebSocket(); - } - - @Bean - public HumanWebSocket humanWebSocket() { - return new HumanWebSocket(); - } - -} \ No newline at end of file +//package com.mcwl.communityCenter.config; +// +//import com.mcwl.communityCenter.webSocket.ChatWebSocket; +//import com.mcwl.communityCenter.webSocket.HumanWebSocket; +//import org.springframework.context.annotation.Bean; +//import org.springframework.context.annotation.Configuration; +//import org.springframework.web.socket.config.annotation.EnableWebSocket; +//import org.springframework.web.socket.config.annotation.WebSocketConfigurer; +//import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; +// +//@Configuration +//@EnableWebSocket +//public class WebSocketConfig implements WebSocketConfigurer { +// +// @Override +// public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { +// registry.addHandler(chatWebSocket(), "/chat") +// .addHandler(humanWebSocket(), "/chat/human") +// .setAllowedOrigins("*"); +// } +// +// @Bean +// public ChatWebSocket chatWebSocket() { +// return new ChatWebSocket(); +// } +// +// @Bean +// public HumanWebSocket humanWebSocket() { +// return new HumanWebSocket(); +// } +// +//} \ No newline at end of file diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/AIServiceImpl.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/AIServiceImpl.java index 0dadcde..a656278 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/AIServiceImpl.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/service/impl/AIServiceImpl.java @@ -1,84 +1,84 @@ -package com.mcwl.communityCenter.service.impl; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mcwl.common.utils.StringUtils; -import com.mcwl.communityCenter.domain.DeepSeekRequest; -import com.mcwl.communityCenter.service.AIService; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Service; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.core.publisher.SignalType; - -import java.util.ArrayList; -import java.util.concurrent.CopyOnWriteArrayList; - -@Service -@RequiredArgsConstructor -public class AIServiceImpl implements AIService { - - @Value("${spring.ai.dashscope.base-url}") - private String DEEPSEEK_API_URL; - @Value("${spring.ai.dashscope.api-key}") - private String API_KEY; - @Value("${spring.ai.dashscope.chat.options.model}") - private String apiModel; - - - private final ObjectMapper objectMapper; - - @Override - public Flux getDeepSeekResponseStream(String message) { - WebClient client = WebClient.builder() - .baseUrl(DEEPSEEK_API_URL) - .defaultHeader("Authorization", "Bearer " + API_KEY) - .build(); - - // 构建请求体(推荐使用对象映射) - DeepSeekRequest request = new DeepSeekRequest(); - request.setModel(apiModel); - // 添加对话历史 - request.addMessage("user", message); - request.setMaxTokens(500); - request.setTemperature(0.7); - request.setStream(true); - - return client.post() - .contentType(MediaType.APPLICATION_JSON) - .bodyValue(request) - .retrieve() - .bodyToFlux(String.class) // 原始数据流 - .takeUntil(data -> data.contains("[DONE]")) // 遇到结束标记停止 - .flatMap(json -> parseContentFromJson(json)) // 解析内容 - .onErrorResume(e -> Flux.just(""));// 错误处理 - - } - - - // 辅助方法:从 JSON 中提取 content - private Mono parseContentFromJson(String json) { - try { - JsonNode root = objectMapper.readTree(json); - String reasoning_content = root.path("choices") - .get(0) - .path("delta") - .path("reasoning_content") - .asText(""); - String content = root.path("choices") - .get(0) - .path("delta") - .path("content") - .asText(""); - System.out.print(StringUtils.isNotEmpty(reasoning_content) ? reasoning_content : content); - return Mono.just(StringUtils.isNotEmpty(reasoning_content) ? reasoning_content : content); - } catch (JsonProcessingException e) { - return Mono.error(e); - } - } - -} +//package com.mcwl.communityCenter.service.impl; +// +//import com.fasterxml.jackson.core.JsonProcessingException; +//import com.fasterxml.jackson.databind.JsonNode; +//import com.fasterxml.jackson.databind.ObjectMapper; +//import com.mcwl.common.utils.StringUtils; +//import com.mcwl.communityCenter.domain.DeepSeekRequest; +//import com.mcwl.communityCenter.service.AIService; +//import lombok.RequiredArgsConstructor; +//import org.springframework.beans.factory.annotation.Value; +//import org.springframework.http.MediaType; +//import org.springframework.stereotype.Service; +//import org.springframework.web.reactive.function.client.WebClient; +//import reactor.core.publisher.Flux; +//import reactor.core.publisher.Mono; +//import reactor.core.publisher.SignalType; +// +//import java.util.ArrayList; +//import java.util.concurrent.CopyOnWriteArrayList; +// +//@Service +//@RequiredArgsConstructor +//public class AIServiceImpl implements AIService { +// +// @Value("${spring.ai.dashscope.base-url}") +// private String DEEPSEEK_API_URL; +// @Value("${spring.ai.dashscope.api-key}") +// private String API_KEY; +// @Value("${spring.ai.dashscope.chat.options.model}") +// private String apiModel; +// +// +// private final ObjectMapper objectMapper; +// +// @Override +// public Flux getDeepSeekResponseStream(String message) { +// WebClient client = WebClient.builder() +// .baseUrl(DEEPSEEK_API_URL) +// .defaultHeader("Authorization", "Bearer " + API_KEY) +// .build(); +// +// // 构建请求体(推荐使用对象映射) +// DeepSeekRequest request = new DeepSeekRequest(); +// request.setModel(apiModel); +// // 添加对话历史 +// request.addMessage("user", message); +// request.setMaxTokens(500); +// request.setTemperature(0.7); +// request.setStream(true); +// +// return client.post() +// .contentType(MediaType.APPLICATION_JSON) +// .bodyValue(request) +// .retrieve() +// .bodyToFlux(String.class) // 原始数据流 +// .takeUntil(data -> data.contains("[DONE]")) // 遇到结束标记停止 +// .flatMap(json -> parseContentFromJson(json)) // 解析内容 +// .onErrorResume(e -> Flux.just(""));// 错误处理 +// +// } +// +// +// // 辅助方法:从 JSON 中提取 content +// private Mono parseContentFromJson(String json) { +// try { +// JsonNode root = objectMapper.readTree(json); +// String reasoning_content = root.path("choices") +// .get(0) +// .path("delta") +// .path("reasoning_content") +// .asText(""); +// String content = root.path("choices") +// .get(0) +// .path("delta") +// .path("content") +// .asText(""); +// System.out.print(StringUtils.isNotEmpty(reasoning_content) ? reasoning_content : content); +// return Mono.just(StringUtils.isNotEmpty(reasoning_content) ? reasoning_content : content); +// } catch (JsonProcessingException e) { +// return Mono.error(e); +// } +// } +// +//} diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/webSocket/ChatWebSocket.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/webSocket/ChatWebSocket.java index dbe9d7e..dbf228e 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/webSocket/ChatWebSocket.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/webSocket/ChatWebSocket.java @@ -1,82 +1,82 @@ -package com.mcwl.communityCenter.webSocket; - -import com.mcwl.communityCenter.service.AIService; -import com.mcwl.communityCenter.service.HumanService; -import lombok.NoArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.socket.CloseStatus; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketSession; -import org.springframework.web.socket.handler.AbstractWebSocketHandler; -import reactor.core.Disposable; -import reactor.core.publisher.Flux; - -import javax.websocket.server.ServerEndpoint; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -@ServerEndpoint("/chat") -@NoArgsConstructor -public class ChatWebSocket extends AbstractWebSocketHandler { - private final Map userModes = new ConcurrentHashMap<>(); - - // 存储会话与订阅的映射关系 - private final Map sessionSubscriptions = new ConcurrentHashMap<>(); - - @Autowired - private AIService aiService; - - // 构造函数注入服务... - - @Override - public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { - String userId = session.getId(); - String userMessage = message.getPayload(); - - // AI 流式响应模式 - Flux responseStream = aiService.getDeepSeekResponseStream(userMessage); - - // 订阅响应流并存储 Disposable - Disposable disposable = responseStream - .doOnNext(chunk -> sendText(session, chunk)) // 发送每个数据块到客户端 - .doOnComplete(() -> sendText(session, "[END]")) // 当流处理完成时,发送结束标记 - .doOnError(e -> sendText(session, "[ERROR] " + e.getMessage())) - .subscribe(); - - sessionSubscriptions.put(userId, disposable); - - } - - @Override - public void afterConnectionEstablished(WebSocketSession session) throws Exception { - super.afterConnectionEstablished(session); -// userModes.put(session.getId(), false); - session.sendMessage(new TextMessage("[AI] 您好,请问有什么问题?")); - } - - @Override - public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { - // 清理订阅资源 - String sessionId = session.getId(); - Disposable disposable = sessionSubscriptions.remove(sessionId); - if (disposable != null && disposable.isDisposed()) { - disposable.dispose(); - } - } - - - - // 线程安全的发送方法 - private void sendText(WebSocketSession session, String text) { - try { - if (session.isOpen()) { - synchronized (session) { // WebSocketSession 非线程安全 - session.sendMessage(new TextMessage(text)); - } - } - } catch (IOException e) { - System.out.println("WebSocket 发送失败: " + e.getMessage()); - } - } -} +//package com.mcwl.communityCenter.webSocket; +// +//import com.mcwl.communityCenter.service.AIService; +//import com.mcwl.communityCenter.service.HumanService; +//import lombok.NoArgsConstructor; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.socket.CloseStatus; +//import org.springframework.web.socket.TextMessage; +//import org.springframework.web.socket.WebSocketSession; +//import org.springframework.web.socket.handler.AbstractWebSocketHandler; +//import reactor.core.Disposable; +//import reactor.core.publisher.Flux; +// +//import javax.websocket.server.ServerEndpoint; +//import java.io.IOException; +//import java.util.Map; +//import java.util.concurrent.ConcurrentHashMap; +// +//@ServerEndpoint("/chat") +//@NoArgsConstructor +//public class ChatWebSocket extends AbstractWebSocketHandler { +// private final Map userModes = new ConcurrentHashMap<>(); +// +// // 存储会话与订阅的映射关系 +// private final Map sessionSubscriptions = new ConcurrentHashMap<>(); +// +// @Autowired +// private AIService aiService; +// +// // 构造函数注入服务... +// +// @Override +// public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { +// String userId = session.getId(); +// String userMessage = message.getPayload(); +// +// // AI 流式响应模式 +// Flux responseStream = aiService.getDeepSeekResponseStream(userMessage); +// +// // 订阅响应流并存储 Disposable +// Disposable disposable = responseStream +// .doOnNext(chunk -> sendText(session, chunk)) // 发送每个数据块到客户端 +// .doOnComplete(() -> sendText(session, "[END]")) // 当流处理完成时,发送结束标记 +// .doOnError(e -> sendText(session, "[ERROR] " + e.getMessage())) +// .subscribe(); +// +// sessionSubscriptions.put(userId, disposable); +// +// } +// +// @Override +// public void afterConnectionEstablished(WebSocketSession session) throws Exception { +// super.afterConnectionEstablished(session); +//// userModes.put(session.getId(), false); +// session.sendMessage(new TextMessage("[AI] 您好,请问有什么问题?")); +// } +// +// @Override +// public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { +// // 清理订阅资源 +// String sessionId = session.getId(); +// Disposable disposable = sessionSubscriptions.remove(sessionId); +// if (disposable != null && disposable.isDisposed()) { +// disposable.dispose(); +// } +// } +// +// +// +// // 线程安全的发送方法 +// private void sendText(WebSocketSession session, String text) { +// try { +// if (session.isOpen()) { +// synchronized (session) { // WebSocketSession 非线程安全 +// session.sendMessage(new TextMessage(text)); +// } +// } +// } catch (IOException e) { +// System.out.println("WebSocket 发送失败: " + e.getMessage()); +// } +// } +//} diff --git a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/webSocket/HumanWebSocket.java b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/webSocket/HumanWebSocket.java index dc09eab..a54cb34 100644 --- a/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/webSocket/HumanWebSocket.java +++ b/mcwl-communityCenter/src/main/java/com/mcwl/communityCenter/webSocket/HumanWebSocket.java @@ -1,55 +1,55 @@ -package com.mcwl.communityCenter.webSocket; - -import com.mcwl.common.utils.SecurityUtils; -import com.mcwl.communityCenter.service.HumanService; -import lombok.NoArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.socket.CloseStatus; -import org.springframework.web.socket.TextMessage; -import org.springframework.web.socket.WebSocketSession; -import org.springframework.web.socket.handler.AbstractWebSocketHandler; -import reactor.core.Disposable; - -import javax.websocket.server.ServerEndpoint; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -@ServerEndpoint("/chat/human") -@NoArgsConstructor -public class HumanWebSocket extends AbstractWebSocketHandler { - - @Autowired - private HumanService humanService; - - // 构造函数注入服务... - - @Override - public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { - String userId = session.getId(); - String userMessage = message.getPayload(); - - humanService.handleHumanMessage(userId, userMessage); - } - - @Override - public void afterConnectionEstablished(WebSocketSession session) throws Exception { - super.afterConnectionEstablished(session); - humanService.transferToHuman(SecurityUtils.getUserId().toString(), session); - System.out.println("客服:" + SecurityUtils.getUsername() + " 已上线"); - } - - - // 线程安全的发送方法 - private void sendText(WebSocketSession session, String text) { - try { - if (session.isOpen()) { - synchronized (session) { // WebSocketSession 非线程安全 - session.sendMessage(new TextMessage(text)); - } - } - } catch (IOException e) { - System.out.println("WebSocket 发送失败: " + e.getMessage()); - } - } -} \ No newline at end of file +//package com.mcwl.communityCenter.webSocket; +// +//import com.mcwl.common.utils.SecurityUtils; +//import com.mcwl.communityCenter.service.HumanService; +//import lombok.NoArgsConstructor; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.socket.CloseStatus; +//import org.springframework.web.socket.TextMessage; +//import org.springframework.web.socket.WebSocketSession; +//import org.springframework.web.socket.handler.AbstractWebSocketHandler; +//import reactor.core.Disposable; +// +//import javax.websocket.server.ServerEndpoint; +//import java.io.IOException; +//import java.util.Map; +//import java.util.concurrent.ConcurrentHashMap; +// +//@ServerEndpoint("/chat/human") +//@NoArgsConstructor +//public class HumanWebSocket extends AbstractWebSocketHandler { +// +// @Autowired +// private HumanService humanService; +// +// // 构造函数注入服务... +// +// @Override +// public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { +// String userId = session.getId(); +// String userMessage = message.getPayload(); +// +// humanService.handleHumanMessage(userId, userMessage); +// } +// +// @Override +// public void afterConnectionEstablished(WebSocketSession session) throws Exception { +// super.afterConnectionEstablished(session); +// humanService.transferToHuman(SecurityUtils.getUserId().toString(), session); +// System.out.println("客服:" + SecurityUtils.getUsername() + " 已上线"); +// } +// +// +// // 线程安全的发送方法 +// private void sendText(WebSocketSession session, String text) { +// try { +// if (session.isOpen()) { +// synchronized (session) { // WebSocketSession 非线程安全 +// session.sendMessage(new TextMessage(text)); +// } +// } +// } catch (IOException e) { +// System.out.println("WebSocket 发送失败: " + e.getMessage()); +// } +// } +//} \ No newline at end of file diff --git a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java index 5bb710b..391c3ed 100644 --- a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java +++ b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java @@ -1,6 +1,8 @@ package com.mcwl.memberCenter.task; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mcwl.common.constant.QueueConstants; import com.mcwl.common.core.domain.entity.SysUser; import com.mcwl.memberCenter.domain.*; @@ -131,16 +133,38 @@ public class UserMemberTask { /** * 会员参与的促销活动是否过期 每天晚上0点检查 0 0 0 * * ? */ + @Transactional(rollbackFor = Exception.class) public void checkPromotionExpiredTask() { - List promotionIdList = new ArrayList<>(); - List promotionList = promotionService.lambdaQuery() - .lt(Promotion::getEndTime, new Date()) // 活动结束日期小于当前时间 - .list(); - for (Promotion promotion : promotionList) { - promotionIdList.add(promotion.getId()); - } + int pageNum = 1; + int pageSize = 1000; + // 根据活动结束日期小于当前时间,获取活动id + List promotionIdList = new ArrayList<>(); + + while (true) { + Page page = new Page<>(pageNum, pageSize); + + promotionService.lambdaQuery() + .lt(Promotion::getEndTime, new Date()) // 活动结束日期小于当前时间 + .page(page); + List promotionList = page.getRecords(); + if (promotionList.isEmpty()) { + break; + } + for (Promotion promotion : promotionList) { + promotionIdList.add(promotion.getId()); + } + + memberPromotionService.lambdaUpdate() + .set(MemberPromotion::getStatus, PromotionEnum.EXPIRED) + .eq(MemberPromotion::getStatus, PromotionEnum.PARTICIPATE) + .in(MemberPromotion::getPromotionId, promotionIdList) + .update(); + pageNum++; + promotionIdList.clear(); + + } } From a17b4667dbe89364cd34ada4e51543f788f35eb0 Mon Sep 17 00:00:00 2001 From: yang <2119157836@qq.com> Date: Fri, 7 Mar 2025 14:32:21 +0800 Subject: [PATCH 6/7] =?UTF-8?q?feat(myInvitation):=20=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mcwl/memberCenter/task/UserMemberTask.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java index 391c3ed..dc9f73a 100644 --- a/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java +++ b/mcwl-memberCenter/src/main/java/com/mcwl/memberCenter/task/UserMemberTask.java @@ -41,7 +41,7 @@ public class UserMemberTask { /** - * 积分清零提醒 月底前五天 0 0 9 L-5 * ? + * 积分重置提醒 月底前五天 0 0 9 L-5 * ? */ public void emptyPointsRemindTask() { List memberList = memberService.getUseUserMember(); @@ -57,6 +57,7 @@ public class UserMemberTask { /** + * 已弃用 * 清空积分 每月月底前两天 0 0 0 L-2 * ? */ @Transactional @@ -117,7 +118,7 @@ public class UserMemberTask { /** - * 会员积分赠送 每月1号 0 0 0 1 * ? + * 重置会员积分 每月1号 0 0 0 1 * ? */ public void givePointsTask() { List memberList = memberService.getUseUserMember(); @@ -147,6 +148,7 @@ public class UserMemberTask { promotionService.lambdaQuery() .lt(Promotion::getEndTime, new Date()) // 活动结束日期小于当前时间 + .orderByAsc(Promotion::getId) .page(page); List promotionList = page.getRecords(); if (promotionList.isEmpty()) { From 583d90f42d09979f4881abf0cb9c132c7ed203cc Mon Sep 17 00:00:00 2001 From: yang <2119157836@qq.com> Date: Fri, 7 Mar 2025 15:24:42 +0800 Subject: [PATCH 7/7] =?UTF-8?q?refactor(pay):=20=E6=8F=90=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myInvitation/InvitationController.java | 7 +++---- .../pay/AliPay/AliPayController.java | 7 +++++-- .../src/main/resources/application-dev.yml | 8 ------- .../system/domain/dto/WithdrawalPageRes.java | 21 +++++++++++++++++++ .../service/ISysUserPayAccountLogService.java | 5 +++-- .../impl/SysUserPayAccountLogServiceImpl.java | 15 +++++++++---- 6 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 mcwl-system/src/main/java/com/mcwl/system/domain/dto/WithdrawalPageRes.java diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java index d887e6e..62d9b0a 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/myInvitation/InvitationController.java @@ -1,15 +1,14 @@ package com.mcwl.web.controller.myInvitation; -import com.mcwl.common.core.domain.AjaxResult; 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.myInvitation.domain.Invitation; import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto; import com.mcwl.myInvitation.service.InvitationService; import com.mcwl.myInvitation.domain.vo.EarningsDisplayVO; +import com.mcwl.system.domain.dto.WithdrawalPageRes; import com.mcwl.system.service.ISysUserPayAccountLogService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -121,9 +120,9 @@ public class InvitationController { */ @PostMapping("withdrawalRecord") @ApiOperation(value = "提现记录") - public TableDataInfo withdrawalRecord(@Valid @RequestBody PageDomain pageDomain) { + public TableDataInfo withdrawalRecord(@Valid @RequestBody WithdrawalPageRes withdrawalPageRes) { - return sysUserPayAccountLogService.getWithdrawalRecord(pageDomain); + return sysUserPayAccountLogService.getWithdrawalRecord(withdrawalPageRes); } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/pay/AliPay/AliPayController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/pay/AliPay/AliPayController.java index 73cbb1c..a42688c 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/pay/AliPay/AliPayController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/pay/AliPay/AliPayController.java @@ -29,7 +29,9 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; import java.io.FileNotFoundException; import java.net.URLEncoder; import java.util.HashMap; @@ -171,8 +173,9 @@ public class AliPayController extends BaseController { @ApiOperation(value = "提现") public R fetch(@Valid @NotNull(message = "提现金额不能为空") - Double amount) throws Exception { - if (amount < 0.1) { + @Pattern(regexp = "^(0|(?!0\\d)[1-9]\\d*)(\\.\\d{2})?$", message = "金额格式错误(必须保留两位小数)") + String amount) throws Exception { + if (Double.parseDouble(amount) < 0.1) { return R.fail("提现金额最小为0.1"); } diff --git a/mcwl-admin/src/main/resources/application-dev.yml b/mcwl-admin/src/main/resources/application-dev.yml index 822d33a..beea40a 100644 --- a/mcwl-admin/src/main/resources/application-dev.yml +++ b/mcwl-admin/src/main/resources/application-dev.yml @@ -99,14 +99,6 @@ spring: # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms time-between-eviction-runs: 6000 - #ai配置 - ai: - dashscope: - base-url: https://api.deepseek.com/chat/completions - api-key: sk-5d1f611b6ba74b90ae9e3dff5aaa508a - chat: - options: - model: deepseek-chat # token配置 diff --git a/mcwl-system/src/main/java/com/mcwl/system/domain/dto/WithdrawalPageRes.java b/mcwl-system/src/main/java/com/mcwl/system/domain/dto/WithdrawalPageRes.java new file mode 100644 index 0000000..70bd562 --- /dev/null +++ b/mcwl-system/src/main/java/com/mcwl/system/domain/dto/WithdrawalPageRes.java @@ -0,0 +1,21 @@ +package com.mcwl.system.domain.dto; + +import com.mcwl.common.core.page.PageDomain; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 提现明细分页请求对象 + */ +@ApiModel(description = "提现明细分页请求对象") +@Data +@EqualsAndHashCode(callSuper = true) +public class WithdrawalPageRes extends PageDomain { + + @ApiModelProperty(value = "用户id") + private Long userId; + + +} diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserPayAccountLogService.java b/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserPayAccountLogService.java index a223260..c1d173c 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserPayAccountLogService.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/ISysUserPayAccountLogService.java @@ -5,6 +5,7 @@ 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.SysUserPayAccountLog; +import com.mcwl.system.domain.dto.WithdrawalPageRes; import javax.validation.Valid; @@ -18,8 +19,8 @@ public interface ISysUserPayAccountLogService extends IService page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); + public TableDataInfo getWithdrawalRecord(WithdrawalPageRes withdrawalPageRes) { + + Long userId = withdrawalPageRes.getUserId(); + userId = Objects.isNull(userId) ? SecurityUtils.getUserId() : userId; + + Page page = new Page<>(withdrawalPageRes.getPageNum(), withdrawalPageRes.getPageSize()); baseMapper.selectPage(page, new LambdaQueryWrapper() .select(SysUserPayAccountLog::getAmount, SysUserPayAccountLog::getAccount, SysUserPayAccountLog::getCreateTime) - .eq(SysUserPayAccountLog::getUserId, SecurityUtils.getUserId())); + .eq(SysUserPayAccountLog::getUserId, userId)); TableDataInfo rspData = new TableDataInfo(); rspData.setCode(HttpStatus.SUCCESS);