Merge branch 'dev/dev' into release/3.0
This commit is contained in:
@@ -12,23 +12,26 @@ public class MQConfig {
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-test";
|
||||
// ==================================================================
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-local";
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-dev";
|
||||
public static final String GENERATE_QUEUE = "generate-queue-prod";
|
||||
public static final String GENERATE_QUEUE = "generate-queue-dev";
|
||||
// public static final String GENERATE_QUEUE = "generate-queue-prod";
|
||||
//
|
||||
// public static final String SR_QUEUE = "SR-queue-local";
|
||||
// public static final String SR_QUEUE = "SR-queue-dev";
|
||||
public static final String SR_QUEUE = "SR-queue-prod";
|
||||
public static final String SR_QUEUE = "SR-queue-dev";
|
||||
// public static final String SR_QUEUE = "SR-queue-prod";
|
||||
//
|
||||
// public static final String SR_RESULT_QUEUE = "SuperResolution-local";
|
||||
// public static final String SR_RESULT_QUEUE = "SuperResolution-dev";
|
||||
public static final String SR_RESULT_QUEUE = "SuperResolution-prod";
|
||||
public static final String SR_RESULT_QUEUE = "SuperResolution-dev";
|
||||
// public static final String SR_RESULT_QUEUE = "SuperResolution-prod";
|
||||
//
|
||||
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-local";
|
||||
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-prod";
|
||||
public static final String GENERATE_RESULT_QUEUE = "GenerateImage-dev";
|
||||
// public static final String GENERATE_RESULT_QUEUE = "GenerateImage-prod";
|
||||
|
||||
public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-prod";
|
||||
public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-dev";
|
||||
// public static final String TO_PRODUCT_IMAGE_RESULT_QUEUE = "ToProductImage-prod";
|
||||
|
||||
public static final String RELIGHT_RESULT_QUEUE = "Relight-prod";
|
||||
public static final String RELIGHT_RESULT_QUEUE = "Relight-dev";
|
||||
// public static final String RELIGHT_RESULT_QUEUE = "Relight-prod";
|
||||
public MQConfig() {
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class MyTaskScheduler {
|
||||
|
||||
// 定时任务,每十五天执行一次
|
||||
// @Scheduled(cron = "0 0 0 ? * MON")
|
||||
@Scheduled(cron = "0 0 0 */15 * ?")
|
||||
// @Scheduled(cron = "0 0 0 */15 * ?")
|
||||
public void checkExpiry() {
|
||||
// 检测正式用户是否快要过期
|
||||
QueryWrapper<Account> qw = new QueryWrapper<>();
|
||||
@@ -83,7 +83,7 @@ public class MyTaskScheduler {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Scheduled(cron = "0 0 8 * * ?")
|
||||
// @Scheduled(cron = "0 0 8 * * ?")
|
||||
public void sendTrialOrderExcelToManagements() {
|
||||
// 获取前一天日期
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
|
||||
@@ -24,14 +24,14 @@ public class AccountTask {
|
||||
accountService.refreshCreditsWeekly();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||
// @Scheduled(cron = "0 */5 * * * *") // Run every 5 minutes
|
||||
public void getPaidUser(){
|
||||
// 获取code-create 表中 指定日期之后 订单状态为wc-processing的订单
|
||||
accountService.extendValidityForCC();
|
||||
}
|
||||
|
||||
// 每天凌晨0点执行一次
|
||||
// @Scheduled(cron = "0 0 0 * * ?")
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void cancelActivityBenefits(){
|
||||
// 1、查询当前所有参与了活动且过期的用户
|
||||
List<Account> accountList = accountService.getExpiredUserBySystemUser(4);
|
||||
@@ -44,7 +44,7 @@ public class AccountTask {
|
||||
}
|
||||
|
||||
// 每天检测正式用户到期情况,每天凌晨0点执行
|
||||
// @Scheduled(cron = "0 0 0 * * ?")
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
public void paidUserToVisitor(){
|
||||
// 1、查询当前已过期正式用户或试用用户
|
||||
List<Account> accountList = accountService.getExpiredUserBySystemUser(1);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class AliPayTask {
|
||||
/**
|
||||
* 从第0秒开始每隔30秒执行1次,查询创建超过5分钟,并且未支付的订单
|
||||
*/
|
||||
// @Scheduled(cron = "0/30 * * * * ?")
|
||||
@Scheduled(cron = "0/30 * * * * ?")
|
||||
public void orderConfirm(){
|
||||
|
||||
// log.info("Alipay orderConfirm 被执行......");
|
||||
|
||||
@@ -4,65 +4,65 @@ package com.ai.da.controller;
|
||||
import com.ai.da.common.context.UserContext;
|
||||
import com.ai.da.common.response.Response;
|
||||
import com.ai.da.mapper.primary.DesignMapper;
|
||||
import com.ai.da.mapper.primary.TrialOrderMapper;
|
||||
import com.ai.da.mapper.primary.entity.Account;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
import com.ai.da.model.dto.AccountAddDTO;
|
||||
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
||||
import com.ai.da.model.vo.QuestionnaireFeedbackVO;
|
||||
import com.ai.da.model.vo.QuestionnaireVO;
|
||||
import com.ai.da.model.vo.QueryUserConditionsVO;
|
||||
import com.ai.da.service.ConvenientInquiryService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@Api(tags = "便利查询")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/inquiry")
|
||||
public class ConvenientInquiryController {
|
||||
|
||||
@Resource
|
||||
private TrialOrderMapper trialOrderMapper;
|
||||
|
||||
@Resource
|
||||
private DesignMapper designMapper;
|
||||
|
||||
@Resource
|
||||
private ConvenientInquiryService convenientInquiryService;
|
||||
|
||||
|
||||
@ApiOperation("获取当前所有试用用户")
|
||||
@GetMapping("/getTrial")
|
||||
public Response<List<TrialOrder>> getTrial(){
|
||||
@PostMapping("/getTrial")
|
||||
public Response<IPage<TrialOrder>> getTrial(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
|
||||
List<TrialOrder> trialOrders = trialOrderMapper.selectList(null);
|
||||
return Response.success(trialOrders);
|
||||
}else {
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)) {
|
||||
return Response.success(convenientInquiryService.getTrial(queryUserConditionsVO));
|
||||
} else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("获取指定时间区间内所有用户design的使用情况")
|
||||
@GetMapping("/getDesignStatistic")
|
||||
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam String startTime,@RequestParam String endTime){
|
||||
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam String startTime, @RequestParam String endTime) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)){
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)) {
|
||||
if (StringUtil.isNullOrEmpty(startTime)) startTime = "2024-02-01 00:00:00";
|
||||
if (StringUtil.isNullOrEmpty(endTime)){
|
||||
if (StringUtil.isNullOrEmpty(endTime)) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
Date date = new Date();
|
||||
endTime = simpleDateFormat.format(date);
|
||||
}
|
||||
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime);
|
||||
return Response.success(designStatistic);
|
||||
}else {
|
||||
} else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
@@ -71,14 +71,94 @@ public class ConvenientInquiryController {
|
||||
//调查问卷
|
||||
@ApiOperation("获取调查问卷统计详情")
|
||||
@GetMapping("/getQuestionnaireStatistic")
|
||||
public Response<QuestionnaireFeedbackVO> getQuestionnaire(){
|
||||
public Response<QuestionnaireFeedbackVO> getQuestionnaire() {
|
||||
return Response.success(convenientInquiryService.getQuestionnaireInfo());
|
||||
}
|
||||
|
||||
@ApiOperation("获取所有调查问卷")
|
||||
@GetMapping("/getAllQuestionnaire")
|
||||
public Response<List<QuestionnaireVO>> getAllQuestionnaire(){
|
||||
public Response<List<QuestionnaireVO>> getAllQuestionnaire() {
|
||||
return Response.success(convenientInquiryService.getAllQuestionnaire());
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期新用户")
|
||||
@PostMapping("/recentNewUser")
|
||||
public Response<IPage<Account>> recentNewUser(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
||||
return Response.success(convenientInquiryService.recentNewUser(queryUserConditionsVO));
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期新用户图表数据")
|
||||
@GetMapping("/recentNewUserChart")
|
||||
public Response<Map<String, Object>> recentNewUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
||||
@ApiParam("userType") @RequestParam Integer userType) {
|
||||
return Response.success(convenientInquiryService.recentNewUserChart(startTime, endTime, userType));
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期活跃用户")
|
||||
@PostMapping("/recentActiveUser")
|
||||
public Response<IPage<Account>> recentActiveUser(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
||||
return Response.success(convenientInquiryService.recentActiveUser(queryUserConditionsVO));
|
||||
}
|
||||
|
||||
@ApiOperation("获取近期活跃用户图表数据")
|
||||
@GetMapping("/recentActiveUserChart")
|
||||
public Response<Integer> recentActiveUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime) {
|
||||
return Response.success(convenientInquiryService.recentActiveUserChart(startTime, endTime));
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户的各模块功能使用详情")
|
||||
@GetMapping("/getActiveUserFunc")
|
||||
public Response<Map<String, List<Object>>> getActiveUserFunc(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
||||
@ApiParam("userIdList") @RequestParam @Nullable List<Long> userIdList) {
|
||||
return Response.success(convenientInquiryService.getActiveUserFunc(startTime, endTime, userIdList));
|
||||
}
|
||||
|
||||
@ApiOperation("试用用户到正式用户的转化率")
|
||||
@GetMapping("/conversionRate")
|
||||
public Response<Map<String, Float>> conversionRate() {
|
||||
return Response.success(convenientInquiryService.conversionRate());
|
||||
}
|
||||
|
||||
@ApiOperation("试用用户国家/城市分布")
|
||||
@GetMapping("/trialUserCountry")
|
||||
public Response<Map<String, List<Object>>> trialUserCountry() {
|
||||
return Response.success(convenientInquiryService.trialUserCountry());
|
||||
}
|
||||
|
||||
@ApiOperation("添加用户")
|
||||
@PostMapping("/addUser")
|
||||
public Response<Boolean> addUser(@Valid @RequestBody AccountAddDTO accountAddDTO) {
|
||||
return Response.success(convenientInquiryService.addUser(accountAddDTO));
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户信息")
|
||||
@PostMapping("/modifyUser")
|
||||
public Response<Boolean> modifyUser(@ApiParam(value = "用户id") @RequestParam @Nullable Long accountId,
|
||||
@ApiParam(value = "有效期截止时间的毫秒级unix格式") @RequestParam @Nullable Long validEndTime,
|
||||
@ApiParam(value = "用户类型 1/2/3/0 -> yearly/monthly/trial/visitor") @RequestParam @Nullable Integer systemUser,
|
||||
@ApiParam("积分") @RequestParam @Nullable Long credits) {
|
||||
return Response.success(convenientInquiryService.modifyUser(accountId, validEndTime, systemUser, credits));
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户信息")
|
||||
@PostMapping("/getUserInfo")
|
||||
public Response<IPage<Account>> getUserInfo(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
||||
Long accountId = UserContext.getUserHolder().getId();
|
||||
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L) || accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)) {
|
||||
return Response.success(convenientInquiryService.getUserInfo(queryUserConditionsVO));
|
||||
} else {
|
||||
return Response.fail("Sorry, you don't have permission");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("获取所有用户id")
|
||||
@GetMapping("/getAllUserId")
|
||||
public Response<List<Map<String, Object>>> getAllUsrIdList() {
|
||||
return Response.success(convenientInquiryService.getAllUserIdList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,5 +3,10 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.Generate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GenerateMapper extends CommonMapper<Generate> {
|
||||
|
||||
List<Map<String, Object>> getByTypeAndTime(String startTime, String endTime, List<Long> accountIdList);
|
||||
}
|
||||
|
||||
@@ -3,5 +3,10 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.ToProductImageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ToProductImageResultMapper extends CommonMapper<ToProductImageResult> {
|
||||
|
||||
List<Map<String, Object>> getByTypeAndTime(String startTime, String endTime, List<Long> accountIdList);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
@@ -11,6 +13,8 @@ import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
*/
|
||||
public interface TrialOrderMapper extends CommonMapper<TrialOrder> {
|
||||
|
||||
Map<String, Long> countOfficialUser();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ai.da.mapper.primary.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -69,11 +70,13 @@ public class Account implements Serializable {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date createDate;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private Date updateDate;
|
||||
|
||||
private Integer isTrial;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ai.da.mapper.primary.entity;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -49,11 +50,13 @@ public class TrialOrder implements Serializable {
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
|
||||
38
src/main/java/com/ai/da/model/vo/QueryUserConditionsVO.java
Normal file
38
src/main/java/com/ai/da/model/vo/QueryUserConditionsVO.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.ai.da.model.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel("按条件筛选试用用户")
|
||||
public class QueryUserConditionsVO extends PageQueryBaseVo {
|
||||
|
||||
|
||||
private List<Long> ids;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String email;
|
||||
|
||||
private String country;
|
||||
|
||||
private String occupation;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String endTime;
|
||||
|
||||
@ApiModelProperty("Ascending(升序) || Descending(降序)")
|
||||
private String order;
|
||||
|
||||
// by id | time | credits
|
||||
private String orderBy;
|
||||
|
||||
private Integer systemUser;
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -855,4 +855,23 @@ public class DesignItemServiceImpl extends ServiceImpl<DesignItemMapper, DesignI
|
||||
} );
|
||||
libraryService.saveBatch(libraries);
|
||||
}
|
||||
|
||||
public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds){
|
||||
QueryWrapper<DesignItem> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.gt("create_date", startTime)
|
||||
.lt("create_date", endTime)
|
||||
.select("count(distinct design_id) as count");
|
||||
|
||||
if (!accountIds.isEmpty()){
|
||||
queryWrapper.in("account_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1284,4 +1284,25 @@ public class DesignServiceImpl extends ServiceImpl<DesignMapper, Design> impleme
|
||||
|
||||
return designMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
// 查询指定用户在指定时间内使用了多少次design
|
||||
public Long getCountByUserAndTime(String startTime, String endTime, List<Long> accountIds){
|
||||
QueryWrapper<Design> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.gt("create_date", startTime)
|
||||
.lt("create_date", endTime)
|
||||
.select("count(id) as count");
|
||||
|
||||
if (!Objects.isNull(accountIds) && !accountIds.isEmpty() ){
|
||||
queryWrapper.in("account_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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#spring.profiles.active=test
|
||||
|
||||
#<23><><EFBFBD><EFBFBD>application-prod<6F>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
spring.profiles.active=prod
|
||||
#spring.profiles.active=prod
|
||||
|
||||
#<23><><EFBFBD><EFBFBD>application-dev<65>ļ<EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
#spring.profiles.active=dev
|
||||
spring.profiles.active=dev
|
||||
|
||||
46
src/main/resources/mapper/primary/GenerateMapper.xml
Normal file
46
src/main/resources/mapper/primary/GenerateMapper.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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.ai.da.mapper.primary.GenerateMapper">
|
||||
<select id="getByTypeAndTime" resultType="java.util.Map">
|
||||
-- 查询level1_type的记录
|
||||
SELECT
|
||||
level1_type as type,
|
||||
count(id) as count
|
||||
FROM
|
||||
t_generate
|
||||
WHERE
|
||||
level1_type IN ('Moodboard', 'Printboard', 'Sketchboard')
|
||||
AND create_date >= #{startTime}
|
||||
AND create_date <= #{endTime}
|
||||
<if test="accountIdList != null and accountIdList.size() > 0">
|
||||
AND account_id IN
|
||||
<foreach item="item" index="index" collection="accountIdList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY
|
||||
level1_type
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- 查询level2_type的记录
|
||||
SELECT
|
||||
level2_type as type,
|
||||
count(id) as count
|
||||
FROM
|
||||
t_generate
|
||||
WHERE
|
||||
level2_type IN ('Pattern', 'Logo', 'Slogan')
|
||||
AND create_date > #{startTime}
|
||||
AND create_date <= #{endTime}
|
||||
<if test="accountIdList != null and accountIdList.size() > 0">
|
||||
AND account_id IN
|
||||
<foreach item="item" index="index" collection="accountIdList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY
|
||||
level2_type;
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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.ai.da.mapper.primary.ToProductImageResultMapper">
|
||||
<select id="getByTypeAndTime" resultType="java.util.Map">
|
||||
select count(a.id) as count, a.result_type type
|
||||
from to_product_image_result as a
|
||||
left join t_user_like_group as b
|
||||
on a.user_like_group_id = b.id
|
||||
where a.create_time >= #{startTime}
|
||||
and a.create_time <= #{endTime}
|
||||
<if test="accountIdList != null and accountIdList.size() > 0">
|
||||
AND account_id IN
|
||||
<foreach item="item" index="index" collection="accountIdList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY type;
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -4,18 +4,24 @@
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.ai.da.mapper.primary.entity.TrialOrder">
|
||||
<id column="id" property="id" />
|
||||
<result column="surname" property="surname" />
|
||||
<result column="given_name" property="givenName" />
|
||||
<result column="user_name" property="userName" />
|
||||
<result column="email" property="email" />
|
||||
<result column="country" property="country" />
|
||||
<result column="occupation" property="occupation" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="status" property="status" />
|
||||
<result column="is_deleted" property="isDeleted" />
|
||||
<id column="id" property="id"/>
|
||||
<result column="surname" property="surname"/>
|
||||
<result column="given_name" property="givenName"/>
|
||||
<result column="user_name" property="userName"/>
|
||||
<result column="email" property="email"/>
|
||||
<result column="country" property="country"/>
|
||||
<result column="occupation" property="occupation"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="countOfficialUser" resultType="java.util.Map">
|
||||
select count(distinct a.user_email) as count
|
||||
from t_account a
|
||||
inner join trial_order b
|
||||
ON a.user_email = b.email
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user