Merge branch 'dev/dev' into release/3.0
This commit is contained in:
@@ -30,4 +30,12 @@ public interface AccountLoginLogService extends IService<AccountLoginLog> {
|
||||
*/
|
||||
List<AccountLoginLog> getByUserId(Long AccountId);
|
||||
|
||||
/**
|
||||
* 查询指定时间区间内的登录用户
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 登录用户id
|
||||
*/
|
||||
List<Long> getByDate(String startTime, String endTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
@@ -149,4 +150,11 @@ public interface AccountService extends IService<Account> {
|
||||
void toVisitor(Account account);
|
||||
|
||||
List<Long> setUserValidToDayEnd();
|
||||
|
||||
IPage<Account> getPageByDateAndUserType(String startTime, String endTime, Integer type, int pageNum, int size);
|
||||
|
||||
Map<String, Long> getByDateAndUserType(String startTime, String endTime, Integer type);
|
||||
|
||||
IPage<Account> getPageByIds(List<Long> ids, int pageNum, int size);
|
||||
List<Account> getByIds(List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.ChatRobot;
|
||||
import com.ai.da.mapper.primary.entity.Library;
|
||||
import com.ai.da.model.dto.ChatFlushDTO;
|
||||
import com.ai.da.model.dto.ChatRobotLibraryDTO;
|
||||
import com.ai.da.model.dto.ChatSendDTO;
|
||||
import com.ai.da.model.vo.ChatRobotVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author aida
|
||||
@@ -15,7 +18,7 @@ import java.math.BigDecimal;
|
||||
* @description 对话机器人服务接口
|
||||
* @date 2023/7/25 16:42:18
|
||||
*/
|
||||
public interface ChatRobotService {
|
||||
public interface ChatRobotService extends IService<ChatRobot> {
|
||||
ChatRobotVO sendMessageToChatRobot(ChatSendDTO chatSendDTO);
|
||||
|
||||
String chatBufferFlush(ChatFlushDTO chatFlushDTO);
|
||||
@@ -23,4 +26,6 @@ public interface ChatRobotService {
|
||||
Library pictureLikeOrUnLike(ChatRobotLibraryDTO chatRobotLibraryDTO);
|
||||
|
||||
BigDecimal getBloodBars(Long userId);
|
||||
|
||||
Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,46 @@
|
||||
package com.ai.da.service;
|
||||
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.Questionnaire;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.AccountAddDTO;
|
||||
import com.ai.da.model.vo.QuestionnaireFeedbackVO;
|
||||
import com.ai.da.model.vo.QuestionnaireVO;
|
||||
import com.ai.da.model.vo.QueryUserConditionsVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ConvenientInquiryService extends IService<Questionnaire> {
|
||||
|
||||
IPage<TrialOrder> getTrial(QueryUserConditionsVO queryUserConditionsVO);
|
||||
|
||||
QuestionnaireFeedbackVO getQuestionnaireInfo();
|
||||
|
||||
List<QuestionnaireVO> getAllQuestionnaire();
|
||||
|
||||
IPage<Account> recentNewUser(QueryUserConditionsVO queryUserConditionsVO);
|
||||
|
||||
Map<String, Object> recentNewUserChart(String startTime, String endTime, Integer userType);
|
||||
|
||||
IPage<Account> recentActiveUser(QueryUserConditionsVO queryUserConditionsVO);
|
||||
|
||||
|
||||
int recentActiveUserChart(String startTime, String endTime);
|
||||
|
||||
Map<String, List<Object>> getActiveUserFunc(String startTime, String endTime, List<Long> ids);
|
||||
|
||||
Map<String, Float> conversionRate();
|
||||
|
||||
Map<String, List<Object>> trialUserCountry();
|
||||
|
||||
Boolean addUser(AccountAddDTO accountAddDTO);
|
||||
|
||||
Boolean modifyUser(Long accountId, Long validEndTime, Integer systemUser, Long credits);
|
||||
|
||||
IPage<Account> getUserInfo(QueryUserConditionsVO queryUserConditionsVO);
|
||||
|
||||
List<Map<String, Object>> getAllUserIdList();
|
||||
}
|
||||
|
||||
@@ -58,4 +58,6 @@ public interface DesignItemService extends IService<DesignItem> {
|
||||
ComposeLayersVO editLayersPositionAndScale(EditLayersPositionAndScaleVO positionAndScaleVO) throws IOException;
|
||||
|
||||
List<DesignItem> selectDesignIdById(List<Long> designItemIdList);
|
||||
|
||||
Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds);
|
||||
}
|
||||
|
||||
@@ -95,4 +95,6 @@ public interface DesignService extends IService<Design> {
|
||||
List<CollectionSketchVO> sketchesBoundingBox(SketchesBoundingBoxDTO sketchesBoundingBoxDTO);
|
||||
|
||||
List<String> getModel(List<Long> designItemIdList);
|
||||
|
||||
Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.ai.da.model.vo.*;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GenerateService extends IService<Generate> {
|
||||
|
||||
@@ -38,4 +39,6 @@ public interface GenerateService extends IService<Generate> {
|
||||
void cancelGenerate(Long userId, List<String> uniqueId, String timeZone, String type);
|
||||
|
||||
void processRelightResult(String taskId, String url, String category);
|
||||
|
||||
List<Map<String, Object>> getCountByUserAndTime(String startTime, String endTime, List<Long> accountIdList);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
//import com.ai.da.common.utils.SendSmsUtil;
|
||||
|
||||
@@ -44,4 +45,14 @@ public class AccountLoginLogServiceImpl extends ServiceImpl<AccountLoginLogMappe
|
||||
queryWrapper.eq("account_id", AccountId);
|
||||
return accountLoginLogMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
public List<Long> getByDate(String startTime, String endTime){
|
||||
QueryWrapper<AccountLoginLog> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.gt("create_date", startTime).lt("create_date", endTime);
|
||||
queryWrapper.select("distinct account_id");
|
||||
|
||||
List<AccountLoginLog> accountLoginLogs = baseMapper.selectList(queryWrapper);
|
||||
return accountLoginLogs.stream().map(AccountLoginLog::getAccountId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,10 +47,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -1348,5 +1345,66 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
return ids;
|
||||
}
|
||||
|
||||
public IPage<Account> getPageByDateAndUserType(String startTime, String endTime, Integer type, int pageNum, int size){
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
setTimeAndSystemUser(queryWrapper,startTime, endTime, type);
|
||||
|
||||
Page<Account> accountPage = new Page<>(pageNum, size);
|
||||
return baseMapper.selectPage(accountPage, queryWrapper);
|
||||
}
|
||||
|
||||
private void setTimeAndSystemUser(QueryWrapper<Account> queryWrapper, String startTime, String endTime, Integer type){
|
||||
queryWrapper.gt("create_date", startTime).lt("create_date",endTime);
|
||||
|
||||
if (!Objects.isNull(type)){
|
||||
switch (type){
|
||||
case 0:
|
||||
// 游客
|
||||
queryWrapper.eq("system_user", 0);
|
||||
break;
|
||||
case 1:
|
||||
queryWrapper.eq("system_user", 1);
|
||||
break;
|
||||
case 2:
|
||||
queryWrapper.eq("system_user", 2);
|
||||
break;
|
||||
case 3:
|
||||
// 试用用户
|
||||
queryWrapper.eq("system_user", 3).or().eq("system_user", 4);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Long> getByDateAndUserType(String startTime, String endTime, Integer type){
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
setTimeAndSystemUser(queryWrapper,startTime, endTime, type);
|
||||
queryWrapper.groupBy("system_user");
|
||||
|
||||
queryWrapper.select("system_user as type, count(id) as count");
|
||||
List<Map<String, Object>> maps = baseMapper.selectMaps(queryWrapper);
|
||||
return maps.stream()
|
||||
.collect(Collectors.toMap(
|
||||
map -> map.get("type").toString(),
|
||||
map -> Objects.isNull(map.get("count")) ? 0L : (Long) map.get("count")));
|
||||
}
|
||||
|
||||
public IPage<Account> getPageByIds(List<Long> ids, int pageNum, int size){
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", ids);
|
||||
|
||||
return baseMapper.selectPage(new Page<>(pageNum, size), queryWrapper);
|
||||
}
|
||||
|
||||
public List<Account> getByIds(List<Long> ids){
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", ids);
|
||||
|
||||
return baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ai.da.common.enums.LibraryLevel1TypeEnum;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.common.utils.MD5Utils;
|
||||
import com.ai.da.common.utils.MinioUtil;
|
||||
import com.ai.da.common.utils.S3Util;
|
||||
import com.ai.da.mapper.primary.AccountMapper;
|
||||
import com.ai.da.mapper.primary.LibraryMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
@@ -26,6 +27,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.minio.errors.MinioException;
|
||||
@@ -56,7 +58,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ChatRobotServiceImpl implements ChatRobotService {
|
||||
public class ChatRobotServiceImpl extends ServiceImpl<ChatRobotMapper, ChatRobot> implements ChatRobotService {
|
||||
|
||||
// @Value("")
|
||||
String chatStreamUrl = "http://18.167.251.121:6789/api/chat_stream";
|
||||
@@ -382,4 +384,23 @@ public class ChatRobotServiceImpl implements ChatRobotService {
|
||||
return "images/female/" + minioPath;
|
||||
}
|
||||
|
||||
public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds){
|
||||
QueryWrapper<ChatRobot> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.gt("create_time", startTime)
|
||||
.lt("create_time", endTime)
|
||||
.select("count(id) as count");
|
||||
|
||||
if (!accountIds.isEmpty()){
|
||||
queryWrapper.in("user_id", accountIds);
|
||||
}
|
||||
|
||||
List<Map<String, Object>> result = baseMapper.selectMaps(queryWrapper);
|
||||
if (result != null && !result.isEmpty()) {
|
||||
Object countObj = result.get(0).get("count");
|
||||
return (Long) countObj;
|
||||
}else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,31 +1,101 @@
|
||||
package com.ai.da.service.impl;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.enums.CreditsEventsEnum;
|
||||
import com.ai.da.common.utils.CopyUtil;
|
||||
import com.ai.da.mapper.primary.AccountMapper;
|
||||
import com.ai.da.mapper.primary.QuestionnaireMapper;
|
||||
import com.ai.da.mapper.primary.ToProductImageResultMapper;
|
||||
import com.ai.da.mapper.primary.TrialOrderMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.Questionnaire;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.AccountAddDTO;
|
||||
import com.ai.da.model.enums.Language;
|
||||
import com.ai.da.model.vo.QuestionnaireFeedbackVO;
|
||||
import com.ai.da.model.vo.QuestionnaireVO;
|
||||
import com.ai.da.service.AccountService;
|
||||
import com.ai.da.service.ConvenientInquiryService;
|
||||
import com.ai.da.model.vo.QueryUserConditionsVO;
|
||||
import com.ai.da.service.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mysql.cj.util.StringUtils;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMapper, Questionnaire> implements ConvenientInquiryService {
|
||||
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
|
||||
@Resource
|
||||
private AccountLoginLogService accountLoginLogService;
|
||||
|
||||
public IPage<TrialOrder> getTrial(QueryUserConditionsVO queryUserConditionsVO) {
|
||||
log.info("getTrial parameter : {},page:{}, size:{}", queryUserConditionsVO, queryUserConditionsVO.getPage(), queryUserConditionsVO.getSize());
|
||||
/* 添加按条件查询试用用户 */
|
||||
// 按用户邮箱/用户名/用户id查指定用户
|
||||
QueryWrapper<TrialOrder> queryWrapper = new QueryWrapper<>();
|
||||
if (!Objects.isNull(queryUserConditionsVO.getIds()) && !queryUserConditionsVO.getIds().isEmpty()) {
|
||||
queryWrapper.in("id", queryUserConditionsVO.getIds());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getUserName())) {
|
||||
queryWrapper.eq("user_name", queryUserConditionsVO.getUserName());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getEmail())) {
|
||||
queryWrapper.eq("email", queryUserConditionsVO.getEmail());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getCountry())) {
|
||||
queryWrapper.eq("country", queryUserConditionsVO.getCountry());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getOccupation())) {
|
||||
queryWrapper.eq("occupation", queryUserConditionsVO.getOccupation());
|
||||
}
|
||||
|
||||
// 按时间区间查
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getStartTime())) {
|
||||
queryWrapper.gt("create_time", queryUserConditionsVO.getStartTime());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getEndTime())) {
|
||||
queryWrapper.lt("create_time", queryUserConditionsVO.getEndTime());
|
||||
}
|
||||
|
||||
// 排序
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getOrder()) && !StringUtils.isNullOrEmpty(queryUserConditionsVO.getOrderBy())) {
|
||||
String orderBy = "id";
|
||||
if (queryUserConditionsVO.getOrderBy().equals("time")) {
|
||||
orderBy = "create_time";
|
||||
}
|
||||
switch (queryUserConditionsVO.getOrder()) {
|
||||
case "Ascending":
|
||||
queryWrapper.orderByAsc(orderBy);
|
||||
break;
|
||||
case "Descending":
|
||||
queryWrapper.orderByDesc(orderBy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 分页查询
|
||||
return trialOrderMapper.selectPage(new Page<>(queryUserConditionsVO.getPage(), queryUserConditionsVO.getSize()), queryWrapper);
|
||||
// List<TrialOrder> trialOrders = trialOrderMapper.selectList(null);
|
||||
}
|
||||
|
||||
|
||||
public QuestionnaireFeedbackVO getQuestionnaireInfo() {
|
||||
String title = "AiDA_3.0 Feedback Survey--06/2024";
|
||||
@@ -181,26 +251,335 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
|
||||
/**
|
||||
* 近期新增用户
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @param userType 用户类型 visitor\trial\official
|
||||
* @return
|
||||
*/
|
||||
public List<Account> recentNewUser(String startTime, String endTime, String userType){
|
||||
return null;
|
||||
/*if (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime) && StringUtil.isNullOrEmpty(userType)){
|
||||
public IPage<Account> recentNewUser(QueryUserConditionsVO queryUserConditionsVO) {
|
||||
log.info("recentActiveUser parameter : {}, page:{}, size:{}", queryUserConditionsVO, queryUserConditionsVO.getPage(), queryUserConditionsVO.getSize());
|
||||
if (StringUtil.isNullOrEmpty(queryUserConditionsVO.getStartTime()) && StringUtil.isNullOrEmpty(queryUserConditionsVO.getEndTime())) {
|
||||
return null;
|
||||
}
|
||||
if (!StringUtil.isNullOrEmpty(queryUserConditionsVO.getStartTime()) && StringUtil.isNullOrEmpty(queryUserConditionsVO.getEndTime())) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
queryUserConditionsVO.setEndTime(LocalDateTime.now().format(formatter));
|
||||
}
|
||||
Integer type = null;
|
||||
if (!Objects.isNull(queryUserConditionsVO.getSystemUser())) {
|
||||
type = queryUserConditionsVO.getSystemUser();
|
||||
}
|
||||
|
||||
int type = userType.equals("visitor") ? 0 : userType.equals("trial") ? 1 : 2;
|
||||
return accountService.getByDateAndUserType(startTime, endTime, type);*/
|
||||
return accountService.getPageByDateAndUserType(queryUserConditionsVO.getStartTime(),
|
||||
queryUserConditionsVO.getEndTime(),
|
||||
type,
|
||||
queryUserConditionsVO.getPage(),
|
||||
queryUserConditionsVO.getSize());
|
||||
}
|
||||
|
||||
// 图表数据
|
||||
public Map<String, Object> recentNewUserChart(String startTime, String endTime, Integer userType) {
|
||||
log.info("recentNewUserChart startTime : {},endTime : {},userType:{}", startTime, endTime, userType);
|
||||
if (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
||||
return null;
|
||||
}
|
||||
if (!StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
endTime = LocalDateTime.now().format(formatter);
|
||||
}
|
||||
|
||||
Map<String, Long> countMap = accountService.getByDateAndUserType(startTime, endTime, userType);
|
||||
long type1 = countMap.get("1") == null ? 0L : countMap.get("1");
|
||||
long type2 = countMap.get("2") == null ? 0L : countMap.get("2");
|
||||
long type3 = countMap.get("3") == null ? 0L : countMap.get("3");
|
||||
long type4 = countMap.get("4") == null ? 0L : countMap.get("4");
|
||||
List<String> names = Arrays.asList("Visitor", "Trials", "Official");
|
||||
List<Long> values = Arrays.asList(countMap.get("0") == null ? 0L : countMap.get("0"),
|
||||
type3 + type4,
|
||||
type1 + type2);
|
||||
|
||||
HashMap<String, Object> resp = new HashMap<>();
|
||||
resp.put("names", names);
|
||||
resp.put("values", values);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
// 近期活跃用户
|
||||
public List<Account> recentActiveUser(String startTime, String endTime){
|
||||
return null;
|
||||
public IPage<Account> recentActiveUser(QueryUserConditionsVO queryUserConditionsVO) {
|
||||
log.info("recentActiveUser parameter : {}, page:{}, size:{}", queryUserConditionsVO, queryUserConditionsVO.getPage(), queryUserConditionsVO.getSize());
|
||||
if (!StringUtil.isNullOrEmpty(queryUserConditionsVO.getStartTime()) && StringUtil.isNullOrEmpty(queryUserConditionsVO.getEndTime())) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
queryUserConditionsVO.setEndTime(LocalDateTime.now().format(formatter));
|
||||
}
|
||||
List<Long> accountIds = accountLoginLogService.getByDate(queryUserConditionsVO.getStartTime(), queryUserConditionsVO.getEndTime());
|
||||
return accountService.getPageByIds(accountIds, queryUserConditionsVO.getPage(), queryUserConditionsVO.getSize());
|
||||
}
|
||||
|
||||
// 图表数据
|
||||
public int recentActiveUserChart(String startTime, String endTime) {
|
||||
if (!StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
endTime = LocalDateTime.now().format(formatter);
|
||||
}
|
||||
List<Long> accountIds = accountLoginLogService.getByDate(startTime, endTime);
|
||||
return accountIds.size();
|
||||
}
|
||||
|
||||
@Resource
|
||||
private GenerateService generateService;
|
||||
@Resource
|
||||
private ToProductImageResultMapper toProductImageResultMapper;
|
||||
@Resource
|
||||
private DesignService designService;
|
||||
@Resource
|
||||
private DesignItemService designItemService;
|
||||
@Resource
|
||||
private ChatRobotService chatRobotService;
|
||||
|
||||
public Map<String, List<Object>> getActiveUserFunc(String startTime, String endTime, List<Long> ids) {
|
||||
|
||||
log.info("getActiveUserFunc ==> startTime:{}, endTime:{}, accountList:{}", startTime, endTime, ids);
|
||||
// 必须指定时间区间
|
||||
if (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
||||
return null;
|
||||
} else if (!StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
endTime = LocalDateTime.now().format(formatter);
|
||||
}
|
||||
|
||||
// design
|
||||
Long designTimes = designService.getCountByUserAndTime(startTime, endTime, ids);
|
||||
|
||||
// single design
|
||||
Long singleDesignTimes = designItemService.getCountByUserAndTime(startTime, endTime, ids);
|
||||
|
||||
// generate -> MoodBoard\PrintBoard\SketchBoard
|
||||
List<Map<String, Object>> countGenerate = generateService.getCountByUserAndTime(startTime, endTime, ids);
|
||||
// 使用Stream API和lambda表达式将数据合并到一个Map中
|
||||
Map<String, Long> countGenerateMerge = countGenerate.stream()
|
||||
.collect(Collectors.toMap(
|
||||
map -> (String) map.get("type"),
|
||||
map -> Objects.isNull(map.get("count")) ? 0L : (Long) map.get("count")));
|
||||
|
||||
// toProductImage\ReLight
|
||||
List<Map<String, Object>> countProduct = toProductImageResultMapper.getByTypeAndTime(startTime, endTime, ids);
|
||||
Map<String, Long> countProductMerge = countProduct.stream()
|
||||
.collect(Collectors.toMap(
|
||||
map -> (String) map.get("type"),
|
||||
map -> Objects.isNull(map.get("count")) ? 0L : (Long) map.get("count")));
|
||||
|
||||
// chatRobot
|
||||
Long chatTimes = chatRobotService.getCountByUserAndTime(startTime, endTime, ids);
|
||||
|
||||
List<Object> names = Arrays.asList("Design", "SingleDesign", "MoodBoard", "PrintBoard", "SketchBoard", "Pattern", "Logo", "Slogan", "ToProductImage", "Relight", "ChatRobot");
|
||||
List<Object> values = Arrays.asList(designTimes, singleDesignTimes,
|
||||
countGenerateMerge.get("Moodboard") == null ? 0L : countGenerateMerge.get("Moodboard"),
|
||||
countGenerateMerge.get("Printboard") == null ? 0L : countGenerateMerge.get("Printboard"),
|
||||
countGenerateMerge.get("Sketchboard") == null ? 0L : countGenerateMerge.get("Sketchboard"),
|
||||
countGenerateMerge.get("Pattern") == null ? 0L : countGenerateMerge.get("Pattern"),
|
||||
countGenerateMerge.get("Logo") == null ? 0L : countGenerateMerge.get("Logo"),
|
||||
countGenerateMerge.get("Slogan") == null ? 0L : countGenerateMerge.get("Slogan"),
|
||||
countProductMerge.get("ToProductImage") == null ? 0L : countProductMerge.get("ToProductImage"),
|
||||
countProductMerge.get("Relight") == null ? 0L : countProductMerge.get("Relight"),
|
||||
chatTimes);
|
||||
|
||||
HashMap<String, List<Object>> resp = new HashMap<>();
|
||||
resp.put("names", names);
|
||||
resp.put("values", values);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Resource
|
||||
private TrialOrderMapper trialOrderMapper;
|
||||
|
||||
// 试用用户到正式用户的转化率
|
||||
public Map<String, Float> conversionRate() {
|
||||
|
||||
QueryWrapper<TrialOrder> queryWrapper = new QueryWrapper<>();
|
||||
// 获取试用用户总数
|
||||
queryWrapper.select("count(distinct email) as count");
|
||||
|
||||
List<Map<String, Object>> trialMaps = trialOrderMapper.selectMaps(queryWrapper);
|
||||
Long totalTrials = (Long) trialMaps.get(0).get("count");
|
||||
|
||||
// 获取从试用用户转为正式用户的用户数量
|
||||
Map<String, Long> officialMaps = trialOrderMapper.countOfficialUser();
|
||||
Long trialToOfficial = officialMaps.get("count");
|
||||
|
||||
// 计算转化率
|
||||
HashMap<String, Float> resp = new HashMap<>();
|
||||
resp.put("trialUserCount", totalTrials.floatValue());
|
||||
resp.put("trialToOfficialCount", trialToOfficial.floatValue());
|
||||
resp.put("conversionRate", new BigDecimal(trialToOfficial).divide(new BigDecimal(totalTrials), 2, RoundingMode.HALF_UP).floatValue());
|
||||
|
||||
return resp;
|
||||
|
||||
}
|
||||
|
||||
// 试用用户地区统计
|
||||
public Map<String, List<Object>> trialUserCountry() {
|
||||
QueryWrapper<TrialOrder> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("country, count(id) as count")
|
||||
.groupBy("country");
|
||||
List<Map<String, Object>> countryCount = trialOrderMapper.selectMaps(queryWrapper);
|
||||
|
||||
Map<Object, Object> countryCountMap = countryCount.stream().collect(Collectors.toMap(
|
||||
map -> map.get("country"),
|
||||
map -> map.get("count")
|
||||
));
|
||||
HashMap<String, List<Object>> resp = new HashMap<>();
|
||||
resp.put("names", new ArrayList<>(countryCountMap.keySet()));
|
||||
resp.put("values", new ArrayList<>(countryCountMap.values()));
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
// 新增用户
|
||||
public Boolean addUser(AccountAddDTO accountAddDTO) {
|
||||
// 需要给的数据 用户邮箱、用户名、账号有效期截止时间、账号类型
|
||||
Account account = CopyUtil.copyObject(accountAddDTO, Account.class);
|
||||
|
||||
// 添加正式用户
|
||||
if (Objects.isNull(accountAddDTO.getSystemUser())) {
|
||||
throw new BusinessException("you have to choose user type");
|
||||
} else {
|
||||
switch (accountAddDTO.getSystemUser()) {
|
||||
case 0:
|
||||
account.setCredits(new BigDecimal(0));
|
||||
account.setIsTrial(0);
|
||||
break;
|
||||
case 1:
|
||||
account.setCredits(new BigDecimal(CreditsEventsEnum.INIT_YEARLY.getValue()));
|
||||
account.setIsTrial(0);
|
||||
break;
|
||||
case 2:
|
||||
account.setCredits(new BigDecimal(CreditsEventsEnum.INIT_MONTHLY.getValue()));
|
||||
account.setIsTrial(0);
|
||||
break;
|
||||
case 3:
|
||||
account.setCredits(new BigDecimal(CreditsEventsEnum.INIT_TRIAL.getValue()));
|
||||
account.setIsTrial(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
account.setValidStartTime(Long.parseLong(accountAddDTO.getValidStartTime()));
|
||||
account.setValidEndTime(Long.parseLong(accountAddDTO.getValidEndTime()));
|
||||
account.setUserPassword("Third-000000");
|
||||
account.setLanguage(Language.ENGLISH.name());
|
||||
account.setCreateDate(new Date());
|
||||
account.setIsBeginner(1);
|
||||
|
||||
log.info("添加用户:{}", accountAddDTO.getUserEmail());
|
||||
return accountService.save(account);
|
||||
}
|
||||
|
||||
// 修改用户信息
|
||||
public Boolean modifyUser(Long accountId, Long validEndTime, Integer systemUser, Long credits) {
|
||||
log.info("modifyUser ==> accountId:{}, validEndTime:{}, systemUser:{}, systemUser:{}", accountId, validEndTime, systemUser, credits);
|
||||
if (Objects.isNull(accountId) && Objects.isNull(validEndTime) && Objects.isNull(systemUser) && Objects.isNull(credits)) {
|
||||
return null;
|
||||
} else if (Objects.isNull(accountId)) {
|
||||
throw new BusinessException("you have to choose a user");
|
||||
}
|
||||
|
||||
Account account = new Account();
|
||||
// 修改用户有效期截止日期、用户类型、积分
|
||||
if (!Objects.isNull(validEndTime)) {
|
||||
account.setValidEndTime(validEndTime);
|
||||
}
|
||||
if (!Objects.isNull(systemUser)) {
|
||||
account.setSystemUser(systemUser);
|
||||
}
|
||||
/*if (!StringUtils.isNullOrEmpty(systemUser)) {
|
||||
int systemUser = 0;
|
||||
switch (systemUser) {
|
||||
case "yearly":
|
||||
systemUser = 1;
|
||||
break;
|
||||
case "monthly":
|
||||
systemUser = 2;
|
||||
break;
|
||||
case "trial":
|
||||
systemUser = 3;
|
||||
break;
|
||||
case "visitor":
|
||||
systemUser = 0;
|
||||
break;
|
||||
}
|
||||
account.setSystemUser(systemUser);
|
||||
}*/
|
||||
if (!Objects.isNull(credits)) {
|
||||
account.setCredits(new BigDecimal(credits));
|
||||
}
|
||||
account.setId(accountId);
|
||||
account.setUpdateDate(new Date());
|
||||
log.info("修改用户信息:{}", accountId);
|
||||
return accountMapper.updateById(account) == 1;
|
||||
// accountService.update(account,null);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private AccountMapper accountMapper;
|
||||
|
||||
// 按条件查询用户信息
|
||||
public IPage<Account> getUserInfo(QueryUserConditionsVO queryUserConditionsVO) {
|
||||
log.info("getUserInfo parameter : {},page:{}, size:{}", queryUserConditionsVO, queryUserConditionsVO.getPage(), queryUserConditionsVO.getSize());
|
||||
// 按用户邮箱/用户名/用户id查指定用户
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
if (!Objects.isNull(queryUserConditionsVO.getIds()) && !queryUserConditionsVO.getIds().isEmpty()) {
|
||||
queryWrapper.in("id", queryUserConditionsVO.getIds());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getUserName())) {
|
||||
queryWrapper.eq("user_name", queryUserConditionsVO.getUserName());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getEmail())) {
|
||||
queryWrapper.eq("user_email", queryUserConditionsVO.getEmail());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getCountry())) {
|
||||
queryWrapper.eq("country", queryUserConditionsVO.getCountry());
|
||||
}
|
||||
if (!Objects.isNull(queryUserConditionsVO.getSystemUser())) {
|
||||
queryWrapper.eq("system_user", queryUserConditionsVO.getSystemUser());
|
||||
}
|
||||
|
||||
// 按时间区间查
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getStartTime())) {
|
||||
queryWrapper.gt("create_date", queryUserConditionsVO.getStartTime());
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getEndTime())) {
|
||||
queryWrapper.lt("create_date", queryUserConditionsVO.getEndTime());
|
||||
}
|
||||
|
||||
// 排序
|
||||
if (!StringUtils.isNullOrEmpty(queryUserConditionsVO.getOrder()) && !StringUtils.isNullOrEmpty(queryUserConditionsVO.getOrderBy())) {
|
||||
String orderBy = "id";
|
||||
switch (queryUserConditionsVO.getOrderBy()) {
|
||||
case "time":
|
||||
orderBy = "create_date";
|
||||
break;
|
||||
case "credits":
|
||||
orderBy = "credits";
|
||||
break;
|
||||
}
|
||||
switch (queryUserConditionsVO.getOrder()) {
|
||||
case "Ascending":
|
||||
queryWrapper.orderByAsc(orderBy);
|
||||
break;
|
||||
case "Descending":
|
||||
queryWrapper.orderByDesc(orderBy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 分页查询
|
||||
return accountMapper.selectPage(new Page<>(queryUserConditionsVO.getPage(), queryUserConditionsVO.getSize()), queryWrapper);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getAllUserIdList() {
|
||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("id as value, user_name as label");
|
||||
|
||||
return accountMapper.selectMaps(queryWrapper);
|
||||
// return maps.stream().map(map -> (Long)map.get("id")).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -237,7 +237,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
// 执行积分扣除
|
||||
// ** 注:如果生成的图片都是空白 则不扣积分
|
||||
if (!status.equals("Invalid")){
|
||||
if (!status.equals("Invalid")) {
|
||||
String accountId = taskId.substring(taskId.lastIndexOf("-") + 1);
|
||||
String uuid = taskId.substring(0, taskId.substring(0, taskId.lastIndexOf("-")).lastIndexOf("-"));
|
||||
Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(accountId), uuid);
|
||||
@@ -270,7 +270,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
|
||||
Long accountId = Long.parseLong(taskId.substring(taskId.lastIndexOf("-") + 1));
|
||||
if (!status.equals("Invalid")){
|
||||
if (!status.equals("Invalid")) {
|
||||
// 4、扣除积分
|
||||
Boolean b = creditsService.taskCreditsDeduction(accountId, taskId);
|
||||
// 3、记录积分变更
|
||||
@@ -778,4 +778,11 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
return baseMapper.selectList(qw);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private GenerateMapper generateMapper;
|
||||
public List<Map<String, Object>> getCountByUserAndTime(String startTime, String endTime, List<Long> accountIdList) {
|
||||
List<Map<String, Object>> byTypeAndTime = generateMapper.getByTypeAndTime(startTime, endTime, accountIdList);
|
||||
return byTypeAndTime;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user