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/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-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..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,29 +1,25 @@ 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.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; 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; -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; @@ -39,6 +35,8 @@ public class InvitationController { private final InvitationService invitationService; + private final ISysUserPayAccountLogService sysUserPayAccountLogService; + /** * 获取邀请码 @@ -103,4 +101,29 @@ public class InvitationController { } + /** + * 累计收入金额 + */ + @GetMapping("totalAmount") + @ApiOperation(value = "累计收入金额") + public R totalAmount() { + Long userId = SecurityUtils.getUserId(); + Double totalAmount = invitationService.getTotalAmount(userId); + if (Objects.isNull(totalAmount)) { + totalAmount = 0.0; + } + return R.ok(totalAmount); + } + + /** + * 提现记录 + */ + @PostMapping("withdrawalRecord") + @ApiOperation(value = "提现记录") + public TableDataInfo withdrawalRecord(@Valid @RequestBody WithdrawalPageRes withdrawalPageRes) { + + 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/java/com/mcwl/web/controller/resource/CollectController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/CollectController.java index a8d9d10..f8e7841 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/CollectController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/CollectController.java @@ -4,9 +4,13 @@ import com.mcwl.common.core.domain.R; import com.mcwl.resource.domain.Collect; import com.mcwl.resource.service.impl.CollectServiceImpl; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * 收藏 @@ -24,6 +28,12 @@ public class CollectController { @Autowired private CollectServiceImpl collectService; + /** + * 添加收藏 + * @param collect + * @return + */ + @ApiOperation(value = "添加收藏") @PostMapping("/addCollect") public R addCollect(@RequestBody Collect collect){ diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/DownloadRecordController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/DownloadRecordController.java new file mode 100644 index 0000000..bd30612 --- /dev/null +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/DownloadRecordController.java @@ -0,0 +1,79 @@ +package com.mcwl.web.controller.resource; + +import com.mcwl.common.core.domain.R; +import com.mcwl.resource.domain.DownloadRecord; +import com.mcwl.resource.domain.vo.PageVo; +import com.mcwl.resource.service.impl.DownloadRecordServiceImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 文件下载记录 + * @author DaiZibo + * @date 2025/3/6 + * @apiNote + */ + + +@Slf4j +@Api(tags = "文件下载记录") +@RestController +@RequestMapping("/downloadRecord") +public class DownloadRecordController { + + + @Autowired + private DownloadRecordServiceImpl downloadRecordService; + + + /** + * 新增下载记录 + * @param downloadRecord + * @return + */ + @ApiOperation(value = "新增下载记录") + @PostMapping("/addDownloadRecord") + public R addDownloadRecord(@RequestBody DownloadRecord downloadRecord){ + + return downloadRecordService.addDownloadRecord(downloadRecord); + } + + /** + * 查询下载记录 + * @param pageVo + * @return + */ + @ApiOperation(value = "下载记录") + @PostMapping("/selectDownloadRecord") + public R selectDownloadRecord(@RequestBody PageVo pageVo){ + + return downloadRecordService.selectDownloadRecord(pageVo); + } + + + /** + * 修改下载状态 + * @return + */ + @ApiOperation(value = "修改下载状态") + @PostMapping("/updateDownloadRecord") + public R updateDownloadRecord(@RequestBody DownloadRecord downloadRecord){ + + return downloadRecordService.updateDownloadRecord(downloadRecord); + } + + /** + * 批量删除下载记录 + * @param ids + * @return + */ + @ApiOperation(value = "批量删除下载记录") + @GetMapping("/deleteDownloadRecord") + public R deleteDownloadRecord(@RequestParam String ids){ + + return downloadRecordService.deleteDownloadRecord(ids); + } +} diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileController.java index 10b29b9..11ac6bb 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/FileController.java @@ -4,6 +4,8 @@ import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.utils.obs.ObsUtils; import com.mcwl.resource.service.impl.FileServiceImpl; import com.mcwl.web.controller.common.OssUtil; +import com.obs.services.ObsClient; +import com.obs.services.model.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -11,8 +13,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import java.io.IOException; +import java.io.*; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -35,6 +39,9 @@ public class FileController { @Autowired private ObsUtils obsUtils; + @Autowired + private ObsClient obsClient; + /*** * * 图片 @@ -128,4 +135,120 @@ public class FileController { return AjaxResult.success(); } + + + /** + * 启动上传任务 + */ + @GetMapping("/getUploadId/{objectKey}") + public String getUploadId(@PathVariable("objectKey")String objectKey) { + InitiateMultipartUploadRequest request = new InitiateMultipartUploadRequest("<桶名称>", objectKey); + ObjectMetadata metadata = new ObjectMetadata(); + metadata.addUserMetadata("property", "property-value"); + metadata.setContentType("text/plain"); + request.setMetadata(metadata); + InitiateMultipartUploadResult result = obsClient.initiateMultipartUpload(request); + String uploadId = result.getUploadId(); + return uploadId; + } + + /** + * 分片上传 + */ + @PostMapping("/chunk") + public Map splitFileUpload( + @RequestParam("objectKey")String objectKey, + @RequestParam("file") MultipartFile file, + @RequestParam("chunk") int chunk, + @RequestParam("uploadId") String uploadId) throws Exception { + File file1 = multipartFileToFile(file); + Map map = uploadChunk(uploadId, file1, chunk, objectKey); + return map; + } + + /** + * 合并上传 + */ + @PostMapping("/completeUpload") + public CompleteMultipartUploadResult completeUpload( + @RequestParam("objectKey")String objectKey, + @RequestParam("uploadId") String uploadId, + @RequestBody List> mapList + ) { + List partEtags = new ArrayList<>(); + for(Map map: mapList ){ + PartEtag part1 = new PartEtag(); + part1.setPartNumber(Integer.valueOf(map.get("partNumber"))); + part1.seteTag(map.get("etag")); + partEtags.add(part1); + } + CompleteMultipartUploadRequest request = new CompleteMultipartUploadRequest( + "<桶名称>", objectKey, uploadId, partEtags); + CompleteMultipartUploadResult result = obsClient.completeMultipartUpload(request); + return result; + } + + /** + * 取消任务上传 + */ + @GetMapping("/cancelUpload") + public void cancelUpload( + @RequestParam("objectKey")String objectKey, + @RequestParam("uploadId") String uploadId + ){ + AbortMultipartUploadRequest request = new AbortMultipartUploadRequest("<桶名称>", objectKey, uploadId); + obsClient.abortMultipartUpload(request); + } + + public Map uploadChunk(String uploadId, File file,int chunk, String objectKey){ + // Endpoint以北京四为例,其他地区请按实际情况填写。 + Map map = new HashMap<>(); + UploadPartRequest request = new UploadPartRequest("<桶名称>", objectKey); + request.setUploadId(uploadId); + request.setPartNumber(chunk); + request.setFile(file); + request.setPartSize(5 * 1024 * 1024L); + UploadPartResult result = obsClient.uploadPart(request); + map.put("etag",result.getEtag()); + map.put("partNumber",String.valueOf(result.getPartNumber())); + return map; + } + + /** + * MultipartFile 转 File + * + * @param file + * @throws Exception + */ + public static File multipartFileToFile(MultipartFile file) throws Exception { + + File toFile = null; + if (file.equals("") || file.getSize() <= 0) { + file = null; + } else { + InputStream ins = null; + ins = file.getInputStream(); + toFile = new File(file.getOriginalFilename()); + inputStreamToFile(ins, toFile); + ins.close(); + } + return toFile; + } + + //获取流文件 + private static void inputStreamToFile(InputStream ins, File file) { + try { + OutputStream os = new FileOutputStream(file); + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + ins.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java index abc93e4..1e2f9d4 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelVersionController.java @@ -6,7 +6,6 @@ import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.resource.domain.ModelVersion; import com.mcwl.resource.service.ModelVersionService; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -96,7 +95,7 @@ public class ModelVersionController extends BaseController { * @param id * @return */ - @ApiModelProperty(value = "下载模型文件") + @ApiOperation(value = "下载模型文件") @GetMapping("/modelFileDownload") public R modelFileDownload(@RequestParam Long id){ diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ToActivityController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ToActivityController.java index e41ef1e..6b94c7f 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ToActivityController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ToActivityController.java @@ -1,7 +1,6 @@ package com.mcwl.web.controller.resource; import com.mcwl.common.core.controller.BaseController; -import com.mcwl.common.core.domain.AjaxResult; import com.mcwl.common.core.domain.R; import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.resource.domain.ToActivity; @@ -26,7 +25,7 @@ import java.util.List; */ @Api(tags = "活动") @RestController -@RequestMapping("ToActivity") +@RequestMapping("/ToActivity") public class ToActivityController extends BaseController { @Autowired private ToActivityService toActivityService; @@ -38,7 +37,7 @@ public class ToActivityController extends BaseController { @PostMapping("/list") public TableDataInfo list(@RequestBody ToActivity toActivity) { -// startPage(); + List list = toActivityService.selectToActivityList(toActivity); return getDataTable(list); } diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowVersionController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowVersionController.java index 84aba8e..c6a76fd 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowVersionController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowVersionController.java @@ -4,7 +4,6 @@ import com.mcwl.common.core.domain.R; import com.mcwl.resource.domain.WorkFlowVersion; import com.mcwl.resource.service.WorkFlowVersionService; import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -47,7 +46,7 @@ public class WorkFlowVersionController { * @param id * @return */ - @ApiModelProperty("下载工作流") + @ApiOperation("下载工作流") @GetMapping("/workFlowFileDownload") public R workFlowFileDownload(@RequestParam Long id){ diff --git a/mcwl-admin/src/main/resources/application-dev.yml b/mcwl-admin/src/main/resources/application-dev.yml index c7c18bb..beea40a 100644 --- a/mcwl-admin/src/main/resources/application-dev.yml +++ b/mcwl-admin/src/main/resources/application-dev.yml @@ -97,15 +97,8 @@ spring: # 连接池的最大数据库连接数 max-active: 1000 # #连接池最大阻塞等待时间(使用负值表示没有限制) - max-wait: -1ms # 默认使用的数据库索引 - #ai配置 - ai: - dashscope: - base-url: https://api.deepseek.com/chat/completions - api-key: sk-5d1f611b6ba74b90ae9e3dff5aaa508a - chat: - options: - model: deepseek-chat + max-wait: -1ms + time-between-eviction-runs: 6000 # token配置 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-admin/src/main/resources/application.yml b/mcwl-admin/src/main/resources/application.yml index 9a99fc0..311a165 100644 --- a/mcwl-admin/src/main/resources/application.yml +++ b/mcwl-admin/src/main/resources/application.yml @@ -57,9 +57,9 @@ spring: servlet: multipart: # 单个文件大小 - max-file-size: 1024MB + max-file-size: 40GB # 设置总上传的文件大小 - max-request-size: 1024MB + max-request-size: 40GB # 服务模块 devtools: restart: diff --git a/mcwl-common/src/main/java/com/mcwl/common/utils/obs/ObsUtils.java b/mcwl-common/src/main/java/com/mcwl/common/utils/obs/ObsUtils.java index 714624f..f46abc5 100644 --- a/mcwl-common/src/main/java/com/mcwl/common/utils/obs/ObsUtils.java +++ b/mcwl-common/src/main/java/com/mcwl/common/utils/obs/ObsUtils.java @@ -69,7 +69,7 @@ public class ObsUtils { now.getYear() + "/" + now.getMonth() + "/" + now.getDayOfMonth() + "/" - + uuid + "_" + + uuid + "/" + name; return url; } 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-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")); 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..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 @@ -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(HttpStatus.WARN,"活动不存在"); + } + + if (promotion.getStartTime().after(new Date())) { + return R.fail(HttpStatus.WARN,"活动未开始"); + } + + // 活动是否过期 + if (promotion.getEndTime().before(new Date())) { + return R.fail(HttpStatus.WARN,"活动已过期"); + } + + // 获取当前用户是否参与过该活动 + if (isJoinPromotion(userId, promotionId)) { + return R.fail(HttpStatus.WARN,"您已参与过该活动"); + } + + // 是否在活动期间内订阅或续订会员 +// 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(HttpStatus.WARN,"会员等级不够,无法参与该活动,请查看活动条件"); + } + 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..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 @@ -1,18 +1,15 @@ 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.Benefit; -import com.mcwl.memberCenter.domain.Member; -import com.mcwl.memberCenter.domain.MemberBenefit; -import com.mcwl.memberCenter.domain.MemberLevel; +import com.mcwl.memberCenter.domain.*; import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum; import com.mcwl.memberCenter.enums.MemberEnum; -import com.mcwl.memberCenter.service.BenefitService; -import com.mcwl.memberCenter.service.MemberBenefitService; -import com.mcwl.memberCenter.service.MemberLevelService; -import com.mcwl.memberCenter.service.MemberService; +import com.mcwl.memberCenter.enums.PromotionEnum; +import com.mcwl.memberCenter.service.*; import com.mcwl.system.service.ISysUserService; import lombok.RequiredArgsConstructor; import org.springframework.amqp.rabbit.core.RabbitTemplate; @@ -38,9 +35,13 @@ public class UserMemberTask { private final BenefitService benefitService; + private final PromotionService promotionService; + + private final MemberPromotionService memberPromotionService; + /** - * 积分清零提醒 月底前五天 0 0 9 L-5 * ? + * 积分重置提醒 月底前五天 0 0 9 L-5 * ? */ public void emptyPointsRemindTask() { List memberList = memberService.getUseUserMember(); @@ -56,6 +57,7 @@ public class UserMemberTask { /** + * 已弃用 * 清空积分 每月月底前两天 0 0 0 L-2 * ? */ @Transactional @@ -116,7 +118,7 @@ public class UserMemberTask { /** - * 会员积分赠送 每月1号 0 0 0 1 * ? + * 重置会员积分 每月1号 0 0 0 1 * ? */ public void givePointsTask() { List memberList = memberService.getUseUserMember(); @@ -129,6 +131,45 @@ public class UserMemberTask { } + /** + * 会员参与的促销活动是否过期 每天晚上0点检查 0 0 0 * * ? + */ + @Transactional(rollbackFor = Exception.class) + public void checkPromotionExpiredTask() { + + 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()) // 活动结束日期小于当前时间 + .orderByAsc(Promotion::getId) + .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(); + + } + } + + /** * 根据会员等级获取积分 */ 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/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 58bb170..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 @@ -1,8 +1,13 @@ package com.mcwl.system.service; 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.SysUserPayAccountLog; +import com.mcwl.system.domain.dto.WithdrawalPageRes; + +import javax.validation.Valid; /** * 用户提现 服务层 @@ -12,4 +17,10 @@ import com.mcwl.system.domain.SysUserPayAccountLog; public interface ISysUserPayAccountLogService extends IService { + /** + * 当前用户的提现记录 + * @param withdrawalPageRes 分页参数 + * @return TableDataInfo + */ + TableDataInfo getWithdrawalRecord(WithdrawalPageRes withdrawalPageRes); } diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserPayAccountLogServiceImpl.java b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserPayAccountLogServiceImpl.java index 4d4d756..7a31842 100644 --- a/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserPayAccountLogServiceImpl.java +++ b/mcwl-system/src/main/java/com/mcwl/system/service/impl/SysUserPayAccountLogServiceImpl.java @@ -1,19 +1,53 @@ 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.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.SysUserPayAccountLog; +import com.mcwl.system.domain.dto.WithdrawalPageRes; import com.mcwl.system.mapper.SysUserPayAccountLogMapper; import com.mcwl.system.mapper.SysUserPayAccountMapper; import com.mcwl.system.service.ISysUserPayAccountLogService; import com.mcwl.system.service.ISysUserPayAccountService; +import org.apache.poi.ss.formula.functions.T; import org.springframework.stereotype.Service; +import java.util.Objects; + /** * 用户提现 */ @Service public class SysUserPayAccountLogServiceImpl extends ServiceImpl implements ISysUserPayAccountLogService { + /** + * 当前用户的提现记录 + * @param withdrawalPageRes 分页参数 + * @return TableDataInfo + */ + @Override + 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, userId)); + + TableDataInfo rspData = new TableDataInfo(); + rspData.setCode(HttpStatus.SUCCESS); + rspData.setMsg("查询成功"); + rspData.setRows(page.getRecords()); + rspData.setTotal(page.getTotal()); + return rspData; + } } 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; }