Merge branch 'preview' of https://gitea.qinmian.online/CY/mcwl-ai into preview

master
ChenYan 2025-03-07 15:29:55 +08:00
commit 206d13ef24
51 changed files with 1384 additions and 466 deletions

View File

@ -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<String> 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<String> switchUserMode(String msg) throws Exception {
// return aiService.getDeepSeekResponseStream(msg);
// }
//
//
//
//}

View File

@ -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<List<Promotion>> promotionList() {
List<Promotion> 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<List<MemberPromotion>> myPromotionList() {
// 获取当前用户
Long userId = SecurityUtils.getUserId();
List<MemberPromotion> 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<Object> joinPromotion(@RequestBody @Valid JoinPromotionDto joinPromotionDto) {
// 用户id
Long userId = joinPromotionDto.getUserId();
// 活动id
Long promotionId = joinPromotionDto.getPromotionId();
// 按活动id查询活动信息
Promotion promotion = promotionService.getById(promotionId);
public R<Object> 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;
}
}

View File

@ -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<Double> 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);
}
}

View File

@ -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<String> 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");
}

View File

@ -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){

View File

@ -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);
}
}

View File

@ -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<String,String> splitFileUpload(
@RequestParam("objectKey")String objectKey,
@RequestParam("file") MultipartFile file,
@RequestParam("chunk") int chunk,
@RequestParam("uploadId") String uploadId) throws Exception {
File file1 = multipartFileToFile(file);
Map<String,String> map = uploadChunk(uploadId, file1, chunk, objectKey);
return map;
}
/**
*
*/
@PostMapping("/completeUpload")
public CompleteMultipartUploadResult completeUpload(
@RequestParam("objectKey")String objectKey,
@RequestParam("uploadId") String uploadId,
@RequestBody List<Map<String,String>> mapList
) {
List<PartEtag> partEtags = new ArrayList<>();
for(Map<String,String> 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<String,String> uploadChunk(String uploadId, File file,int chunk, String objectKey){
// Endpoint以北京四为例其他地区请按实际情况填写。
Map<String,String> 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();
}
}
}

View File

@ -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){

View File

@ -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<ToActivity> list = toActivityService.selectToActivityList(toActivity);
return getDataTable(list);
}

View File

@ -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){

View File

@ -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配置

View File

@ -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配置

View File

@ -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:

View File

@ -69,7 +69,7 @@ public class ObsUtils {
now.getYear() + "/" +
now.getMonth() + "/" +
now.getDayOfMonth() + "/"
+ uuid + "_"
+ uuid + "/"
+ name;
return url;
}

View File

@ -38,17 +38,17 @@
<!-- <artifactId>dashscope-sdk-java</artifactId>-->
<!-- <version>2.18.3</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.alibaba.cloud.ai</groupId>
<artifactId>spring-ai-alibaba-starter</artifactId>
<version>1.0.0-M5.1</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud.ai</groupId>-->
<!-- <artifactId>spring-ai-alibaba-starter</artifactId>-->
<!-- <version>1.0.0-M5.1</version>-->
<!-- </dependency>-->
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty-http</artifactId>
<version>1.1.6</version> <!-- 使用与你的 Spring Boot 版本兼容的版本 -->
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.projectreactor.netty</groupId>-->
<!-- <artifactId>reactor-netty-http</artifactId>-->
<!-- <version>1.1.6</version> &lt;!&ndash; 使用与你的 Spring Boot 版本兼容的版本 &ndash;&gt;-->
<!-- </dependency>-->
</dependencies>

View File

@ -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();
}
}
//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();
// }
//
//}

View File

@ -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<String> 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<String> 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<String> 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<String> 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);
// }
// }
//
//}

View File

@ -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<String, Boolean> userModes = new ConcurrentHashMap<>();
// 存储会话与订阅的映射关系
private final Map<String, Disposable> 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<String> 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<String, Boolean> userModes = new ConcurrentHashMap<>();
//
// // 存储会话与订阅的映射关系
// private final Map<String, Disposable> 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<String> 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());
// }
// }
//}

View File

@ -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());
}
}
}
//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());
// }
// }
//}

View File

@ -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"));

View File

@ -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;
}

View File

@ -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<Promotion> {
/**
*
* @return TableDataInfo
*/
TableDataInfo getPromotionList(PageDomain pageDomain);
TableDataInfo getMyPromotionList(PageDomain pageDomain);
R<Object> joinPromotion(Long promotionId);
}

View File

@ -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<PromotionMapper, Promotion> implements PromotionService {
private final MemberPromotionService memberPromotionService;
private final MemberService memberService;
/**
*
*
* @return TableDataInfo
*/
@Override
public TableDataInfo getPromotionList(PageDomain pageDomain) {
// 封装用户参加的促销活动, key为促销活动id, value为用户参加的促销活动
Map<Long, MemberPromotion> map = new HashMap<>();
// 获取用户参加的促销活动
Long userId = SecurityUtils.getUserId();
List<MemberPromotion> memberPromotionList = memberPromotionService.lambdaQuery()
.eq(MemberPromotion::getUserId, userId)
.eq(MemberPromotion::getStatus, PromotionEnum.PARTICIPATE)
.list();
for (MemberPromotion memberPromotion : memberPromotionList) {
map.put(memberPromotion.getPromotionId(), memberPromotion);
}
// 查询促销活动列表
Page<Promotion> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
LambdaQueryWrapper<Promotion> lqw = new LambdaQueryWrapper<>();
lqw.gt(Promotion::getEndTime, new Date());
baseMapper.selectPage(page, lqw);
// 封装数据
List<PromotionVo> 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<Long> memberPromotionIds = new ArrayList<>();
// 默认添加一个不存在的id, 防止List为空时in查询出错
memberPromotionIds.add(-1L);
// 查询用户参加的促销活动
List<MemberPromotion> memberPromotionList = memberPromotionService.lambdaQuery()
.eq(MemberPromotion::getUserId, userId)
.eq(MemberPromotion::getStatus, PromotionEnum.PARTICIPATE)
.list();
for (MemberPromotion memberPromotion : memberPromotionList) {
memberPromotionIds.add(memberPromotion.getPromotionId());
}
// 查询促销活动列表
Page<Promotion> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
LambdaQueryWrapper<Promotion> lqw = new LambdaQueryWrapper<>();
lqw.in(Promotion::getId, memberPromotionIds);
baseMapper.selectPage(page, lqw);
// 封装数据
List<PromotionVo> 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<Object> 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;
}
}

View File

@ -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<Member> 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<Member> 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<Long> promotionIdList = new ArrayList<>();
while (true) {
Page<Promotion> page = new Page<>(pageNum, pageSize);
promotionService.lambdaQuery()
.lt(Promotion::getEndTime, new Date()) // 活动结束日期小于当前时间
.orderByAsc(Promotion::getId)
.page(page);
List<Promotion> 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();
}
}
/**
*
*/

View File

@ -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;
}

View File

@ -45,11 +45,10 @@ public class ConsumeServiceImpl extends ServiceImpl<ConsumeMapper, Consume> 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);

View File

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

View File

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

View File

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

View File

@ -0,0 +1,97 @@
package com.mcwl.resource.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
*
*
* @author DaiZibo
* @date 2025/3/6
* @apiNote
*/
@TableName("download_record")
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DownloadRecord {
/**
* ID
*/
@ApiModelProperty(value = "主键ID")
private Long id;
/**
* ID
*/
@ApiModelProperty(value = "下载作品ID")
private Long productId;
/**
* ID
*/
@ApiModelProperty(value = "下载人ID")
private Long userId;
/**
* 0 1
*/
@ApiModelProperty(value = "作品类型0模型 1工作流")
private Long productType;
/**
*
*/
@ApiModelProperty(value = "文件名字")
private String fileName;
/**
*
*/
@ApiModelProperty(value = "封面图")
private String cover;
/**
*
*/
@ApiModelProperty(value = "作者名字")
private String authorName;
/**
*
*/
@ApiModelProperty(value = "网站地址")
private String website;
/**
*
*/
@ApiModelProperty(value = "文件大小")
private String fileSize;
/**
* ()
*/
@ApiModelProperty(value = "状态(下载中,已暂停,下载完成)")
private Long status;
/**
*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ApiModelProperty(value = "创建日期")
private Date createTime;
}

View File

@ -11,8 +11,6 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
*
* @AuthorChenYan
@ -144,13 +142,13 @@ public class ModelProduct extends BaseEntity {
private Double productPrice;
/**
*
*/
@ApiModelProperty(value = "翻译后标签")
@TableField(exist = false)
private List<String> styleList;
//
// /**
// * 翻译后标签
// */
// @ApiModelProperty(value = "翻译后标签")
// @TableField(exist = false)
// private List<String> styleList;
/**
@ -161,11 +159,12 @@ public class ModelProduct extends BaseEntity {
private Integer isAttention;
/**
/**R
* 0 1
*/
@ApiModelProperty(value = "是否点赞 0未点赞 1点赞")
@TableField(exist = false)
private Integer isLike;
}

View File

@ -194,5 +194,11 @@ public class ModelVersion extends BaseEntity {
@TableField(exist = false)
private ArrayList<String> highList;
/**
*
*/
@ApiModelProperty(value = "是否收藏")
@TableField(exist = false)
private Integer isCollect = 1;
}

View File

@ -97,4 +97,11 @@ public class WorkFlowVersion {
*/
@ApiModelProperty(value = "文件大小")
private String fileSize;
/**
*
*/
@TableField(exist = false)
@ApiModelProperty(value = "是否收藏")
private Integer isCollect =1;
}

View File

@ -15,4 +15,6 @@ import org.apache.ibatis.annotations.Param;
public interface CollectMapper extends BaseMapper<Collect> {
Collect selectCollect(@Param("userId") Long userId, @Param("productId") Long productId, @Param("productType") Long productType);
Collect selectCollectById(@Param("modelId") Long modelId, @Param("userIdMax") Long userIdMax, @Param("type") Integer type);
}

View File

@ -0,0 +1,17 @@
package com.mcwl.resource.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mcwl.resource.domain.DownloadRecord;
import org.apache.ibatis.annotations.Mapper;
/**
* @author DaiZibo
* @date 2025/3/6
* @apiNote
*/
@Mapper
public interface DownloadRecordMapper extends BaseMapper<DownloadRecord> {
void updateDownloadRecord(DownloadRecord downloadRecord);
}

View File

@ -12,4 +12,6 @@ import com.mcwl.resource.domain.Collect;
public interface CollectService {
R addCollect(Collect collect);
Collect selectCollectById(Long modelId, Long userIdMax,Integer type);
}

View File

@ -0,0 +1,22 @@
package com.mcwl.resource.service;
import com.mcwl.common.core.domain.R;
import com.mcwl.resource.domain.DownloadRecord;
import com.mcwl.resource.domain.vo.PageVo;
/**
* @author DaiZibo
* @date 2025/3/6
* @apiNote
*/
public interface DownloadRecordService {
R addDownloadRecord(DownloadRecord downloadRecord);
R selectDownloadRecord(PageVo pageVo);
R updateDownloadRecord(DownloadRecord downloadRecord);
R deleteDownloadRecord(String ids);
}

View File

@ -8,6 +8,8 @@ import com.mcwl.resource.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
*
* @author DaiZibo
@ -26,7 +28,8 @@ public class CollectServiceImpl implements CollectService {
public R addCollect(Collect collect) {
Collect collect1 = collectMapper.selectCollect(SecurityUtils.getUserId(),collect.getProductId(),collect.getProductType());
collect.setUserId(SecurityUtils.getUserId());
collect.setCreateTime(new Date());
if (collect1 == null){
//执行收藏
collectMapper.insert(collect);
@ -38,4 +41,10 @@ public class CollectServiceImpl implements CollectService {
return R.ok(1);
}
@Override
public Collect selectCollectById(Long modelId, Long userIdMax,Integer type) {
return collectMapper.selectCollectById(modelId,userIdMax,type);
}
}

View File

@ -0,0 +1,138 @@
package com.mcwl.resource.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.*;
import com.mcwl.resource.domain.vo.PageVo;
import com.mcwl.resource.mapper.*;
import com.mcwl.resource.service.DownloadRecordService;
import com.mcwl.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
*
*
* @author DaiZibo
* @date 2025/3/6
* @apiNote
*/
@Service
public class DownloadRecordServiceImpl implements DownloadRecordService {
@Autowired
private DownloadRecordMapper downloadRecordMapper;
@Autowired
private ModelVersionMapper modelVersionMapper;
@Autowired
private WorkFlowVersionMapper workFlowVersionMapper;
@Autowired
private WorkFlowMapper workFlowMapper;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private ModelMapper modelMapper;
@Override
public R addDownloadRecord(DownloadRecord downloadRecord) {
//获取下载人
downloadRecord.setUserId(SecurityUtils.getUserId());
downloadRecord.setCreateTime(new Date());
//获取作品信息
if (downloadRecord.getProductType() == 0){
//查询文件/名称信息
ModelVersion modelVersion = modelVersionMapper.selectById(downloadRecord.getProductId());
downloadRecord.setFileName(modelVersion.getFileName());
downloadRecord.setFileSize(modelVersion.getFileSize());
//根据版本查找封面信息
ModelProduct modelProduct = modelMapper.selectById(modelVersion.getModelId());
downloadRecord.setCover(modelProduct.getSurfaceUrl());
//查询作者信息
SysUser sysUser = sysUserMapper.selectUserById(modelProduct.getUserId());
downloadRecord.setAuthorName(sysUser.getNickName());
}else {
//查询文件/名称信息
WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectById(downloadRecord.getProductId());
downloadRecord.setFileName(workFlowVersion.getFileName());
downloadRecord.setFileSize(workFlowVersion.getFileSize());
//根据版本查找封面信息
WorkFlow workFlow = workFlowMapper.selectById(workFlowVersion.getWorkFlowId());
downloadRecord.setCover(workFlow.getCoverPath());
//查询作者信息
SysUser sysUser = sysUserMapper.selectUserById(workFlow.getUserId());
downloadRecord.setAuthorName(sysUser.getNickName());
}
downloadRecordMapper.insert(downloadRecord);
return R.ok();
}
@Override
public R selectDownloadRecord(PageVo pageVo) {
//分页查询数据
Page<DownloadRecord> page = new Page<>();
page.setSize(pageVo.getPageSize());
page.setPages(pageVo.getPageNumber());
LambdaQueryWrapper<DownloadRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DownloadRecord::getUserId,SecurityUtils.getUserId());
wrapper.eq(pageVo.getType() != null,DownloadRecord::getProductType,pageVo.getType());
Page<DownloadRecord> downloadRecordPage = downloadRecordMapper.selectPage(page, wrapper);
return R.ok(downloadRecordPage);
}
@Override
public R updateDownloadRecord(DownloadRecord downloadRecord) {
downloadRecordMapper.updateDownloadRecord(downloadRecord);
return R.ok();
}
@Override
public R deleteDownloadRecord(String ids) {
if (StringUtils.isNotBlank(ids)) {
List<Long> idList = Arrays.stream(ids.split(","))
.filter(StringUtils::isNotBlank)
.map(Long::valueOf)
.collect(Collectors.toList());
if (!idList.isEmpty()) {
downloadRecordMapper.deleteBatchIds(idList);
}
return R.ok();
}
return R.fail("请选择要删除的数据");
}
}

View File

@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
* @author DaiZibo
* @date 2025/2/14
* @apiNote

View File

@ -467,6 +467,8 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
log.info("开始拉取文件...");
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("objectKey",key);
log.info("整体版本数据:{}",modelVersion);
log.info("拉取文件数据:{}",key);
hashMap.put("type",DictInit.getDictValue(DictConstants.MODEL_TYPE,modelProduct.getModelType()+""));
String s = HttpUtils.pythonPost("http://1.13.246.108:8188/api/experiment/models/upload", hashMap);
log.info("文件拉取结果:{}",s);
@ -502,16 +504,17 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
//标签
if (StringUtils.isNotEmpty(modelProduct.getTags())){
ArrayList<String> strings = new ArrayList<>();
String[] split = modelProduct.getTags().split(",");
for (String s : split) {
if (s != ""){
strings.add(s);
}
}
modelProduct.setStyleList(strings);
}
// if (StringUtils.isNotEmpty(modelProduct.getTags())){
// ArrayList<String> strings = new ArrayList<>();
// String[] split = modelProduct.getTags().split(",");
// for (String s : split) {
// if (s != ""){
// strings.add(s);
// }
// }
// modelProduct.setStyleList(strings);
// }
// modelProduct.setStyleList(new ArrayList<>());
//功能
if (StringUtils.isNotEmpty(modelProduct.getFunctions())){

View File

@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.constant.DictConstants;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.Collect;
import com.mcwl.resource.domain.ModelVersion;
import com.mcwl.resource.mapper.ModelMapper;
import com.mcwl.resource.mapper.ModelVersionMapper;
import com.mcwl.resource.service.ModelVersionService;
import com.mcwl.system.init.DictInit;
@ -29,6 +32,12 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
@Autowired
private ModelVersionService modelVersionService;
@Autowired
private CollectServiceImpl collectService;
@Autowired
private ModelMapper modelMapper;
@Autowired
private ModelVersionMapper modelVersionMapper;
@ -87,9 +96,23 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
List<ModelVersion> modelVersions = baseMapper.selectList(modelVersionLambdaQueryWrapper);
// for (ModelVersion modelVersion : modelVersions) {
//
// }
Long userIdMax = SecurityUtils.getUserIdMax();
if (userIdMax != 0){
for (ModelVersion modelVersion : modelVersions) {
modelVersion.setFilePath("");
modelVersion.setEncryptionFilePath("");
//模型字典 0 工作流字典 1
Integer type = 0;
//校验是否收藏
Collect collect = collectService.selectCollectById(modelVersion.getModelId(),userIdMax,type);
if (collect != null ){
modelVersion.setIsCollect(0);
}
}
}
return modelVersions;
}
@ -98,11 +121,19 @@ public class ModelVersionServiceImpl extends ServiceImpl< ModelVersionMapper,Mo
public R modelFileDownload(Long id) {
ModelVersion modelVersion = modelVersionMapper.selectById(id);
if (modelVersion == null){
return R.fail("文件为空");
}
if (modelVersion.getAllowDownloadImage().equals(0)){
return R.fail("此文件不可下载");
}
return R.ok();
if (modelVersion.getIsEncrypt() == 1){
return R.ok(modelVersion.getEncryptionFilePath());
}
return R.ok(modelVersion.getFilePath(),modelVersion.getFileName());
}

View File

@ -334,6 +334,7 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
LambdaQueryWrapper<WorkFlow> lambdaQueryWrapper = Wrappers.<WorkFlow>lambdaQuery()
.like(StringUtils.isNotBlank(pageVo.getName()), WorkFlow::getWorkflowName, pageVo.getName())
.eq(WorkFlow::getAuditStatus,1)
.eq(WorkFlow::getDelFlag, 0);
if (pageVo.getOrder() == 1) {

View File

@ -2,6 +2,8 @@ package com.mcwl.resource.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.resource.domain.Collect;
import com.mcwl.resource.domain.WorkFlow;
import com.mcwl.resource.domain.WorkFlowVersion;
import com.mcwl.resource.mapper.WorkFlowMapper;
@ -14,6 +16,7 @@ import java.util.List;
/**
*
*
* @author DaiZibo
* @date 2025/1/9
* @apiNote
@ -28,6 +31,10 @@ public class WorkFlowVersionServiceImpl implements WorkFlowVersionService {
@Autowired
private WorkFlowMapper workFlowMapper;
@Autowired
private CollectServiceImpl collectService;
@Override
public R<List<WorkFlowVersion>> selectVersionByWorkId(Long workId) {
@ -37,6 +44,19 @@ public class WorkFlowVersionServiceImpl implements WorkFlowVersionService {
workFlowVersionLambdaQueryWrapper.eq(WorkFlowVersion::getWorkFlowId, workId);
List<WorkFlowVersion> workFlowVersions = workFlowVersionMapper.selectList(workFlowVersionLambdaQueryWrapper);
Long userIdMax = SecurityUtils.getUserIdMax();
if (userIdMax != 0) {
for (WorkFlowVersion workFlowVersion : workFlowVersions) {
workFlowVersion.setFilePath("");
//模型字典 0 工作流字典 1
Integer type = 0;
//校验是否收藏
Collect collect = collectService.selectCollectById(workFlowVersion.getWorkFlowId(), userIdMax, type);
if (collect != null) {
workFlowVersion.setIsCollect(0);
}
}
}
return R.ok(workFlowVersions);
}
@ -55,6 +75,6 @@ public class WorkFlowVersionServiceImpl implements WorkFlowVersionService {
return R.fail("该文件不允许下载");
}
return R.ok(workFlowVersion.getFilePath());
return R.ok(workFlowVersion.getFilePath(), workFlowVersion.getFileName());
}
}

View File

@ -10,4 +10,10 @@
FROM collect where product_id = #{productId} and user_id = #{userId} and product_type = #{productType}
</select>
<select id="selectCollectById" resultType="com.mcwl.resource.domain.Collect">
select
id,product_id,user_id,product_type
FROM collect where product_id = #{modelId} and user_id = #{userIdMax} and product_type = #{type}
</select>
</mapper>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mcwl.resource.mapper.DownloadRecordMapper">
<update id="updateDownloadRecord">
UPDATE download_record
SET file_size = #{fileSize},
status = #{status}
WHERE id = #{id}
</update>
</mapper>

View File

@ -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
<if test="name != null and name != ''">
and m.model_name like CONCAT('%', #{name}, '%')
</if>

View File

@ -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;
}

View File

@ -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<SysUserPayAccountLog> {
/**
*
* @param withdrawalPageRes
* @return TableDataInfo
*/
TableDataInfo getWithdrawalRecord(WithdrawalPageRes withdrawalPageRes);
}

View File

@ -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<SysUserPayAccountLogMapper, SysUserPayAccountLog> implements ISysUserPayAccountLogService {
/**
*
* @param withdrawalPageRes
* @return TableDataInfo
*/
@Override
public TableDataInfo getWithdrawalRecord(WithdrawalPageRes withdrawalPageRes) {
Long userId = withdrawalPageRes.getUserId();
userId = Objects.isNull(userId) ? SecurityUtils.getUserId() : userId;
Page<SysUserPayAccountLog> page = new Page<>(withdrawalPageRes.getPageNum(), withdrawalPageRes.getPageSize());
baseMapper.selectPage(page, new LambdaQueryWrapper<SysUserPayAccountLog>()
.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;
}
}

View File

@ -612,9 +612,10 @@ public class SysUserServiceImpl implements ISysUserService
@Override
public SysUser selectUserInfoById(Long userId) {
SysUser sysUser = userMapper.selectUserInfoById(userId);
if (sysUser.getInviterUserId() != null){
SysUser sysUser1 = selectUserById(sysUser.getInviterUserId());
sysUser.setInvitationName(sysUser1.getNickName());
}
return sysUser;
}