2024-03-04 16:33:23 +08:00
|
|
|
package com.ai.da.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ai.da.common.context.UserContext;
|
2025-01-10 13:27:27 +08:00
|
|
|
import com.ai.da.common.response.PageBaseResponse;
|
2024-03-04 16:33:23 +08:00
|
|
|
import com.ai.da.common.response.Response;
|
2024-03-15 15:38:56 +08:00
|
|
|
import com.ai.da.mapper.primary.DesignMapper;
|
2024-08-01 10:00:26 +08:00
|
|
|
import com.ai.da.mapper.primary.entity.Account;
|
2024-03-15 15:38:56 +08:00
|
|
|
import com.ai.da.mapper.primary.entity.TrialOrder;
|
2024-08-05 15:19:02 +08:00
|
|
|
import com.ai.da.model.dto.AccountAddDTO;
|
2025-01-10 13:27:27 +08:00
|
|
|
import com.ai.da.model.dto.QueryPaymentInfoDTO;
|
2024-03-04 16:33:23 +08:00
|
|
|
import com.ai.da.model.dto.UserDesignStatisticDTO;
|
2025-01-10 13:27:27 +08:00
|
|
|
import com.ai.da.model.vo.PaymentInfoVO;
|
2024-07-29 17:24:14 +08:00
|
|
|
import com.ai.da.model.vo.QuestionnaireFeedbackVO;
|
|
|
|
|
import com.ai.da.model.vo.QuestionnaireVO;
|
2024-08-05 15:19:02 +08:00
|
|
|
import com.ai.da.model.vo.QueryUserConditionsVO;
|
2025-01-07 17:27:29 +08:00
|
|
|
import com.ai.da.service.AccountService;
|
2024-07-29 17:24:14 +08:00
|
|
|
import com.ai.da.service.ConvenientInquiryService;
|
2024-08-01 10:00:26 +08:00
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
2024-04-22 13:09:44 +08:00
|
|
|
import io.netty.util.internal.StringUtil;
|
2024-03-04 16:33:23 +08:00
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
2024-08-01 10:00:26 +08:00
|
|
|
import io.swagger.annotations.ApiParam;
|
2024-03-04 16:33:23 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
2024-08-01 10:00:26 +08:00
|
|
|
import javax.annotation.Nullable;
|
2024-03-04 16:33:23 +08:00
|
|
|
import javax.annotation.Resource;
|
2025-01-24 13:26:53 +08:00
|
|
|
import javax.servlet.http.HttpServletResponse;
|
2024-08-05 15:19:02 +08:00
|
|
|
import javax.validation.Valid;
|
2024-04-22 13:09:44 +08:00
|
|
|
import java.text.SimpleDateFormat;
|
2024-08-01 10:00:26 +08:00
|
|
|
import java.util.*;
|
2024-03-04 16:33:23 +08:00
|
|
|
|
|
|
|
|
@Api(tags = "便利查询")
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/inquiry")
|
|
|
|
|
public class ConvenientInquiryController {
|
|
|
|
|
@Resource
|
|
|
|
|
private DesignMapper designMapper;
|
2024-07-29 17:24:14 +08:00
|
|
|
@Resource
|
|
|
|
|
private ConvenientInquiryService convenientInquiryService;
|
2025-01-07 17:27:29 +08:00
|
|
|
@Resource
|
|
|
|
|
private AccountService accountService;
|
2024-07-29 17:24:14 +08:00
|
|
|
|
|
|
|
|
|
2024-03-04 16:33:23 +08:00
|
|
|
@ApiOperation("获取当前所有试用用户")
|
2024-08-05 15:19:02 +08:00
|
|
|
@PostMapping("/getTrial")
|
|
|
|
|
public Response<IPage<TrialOrder>> getTrial(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
2024-03-04 16:33:23 +08:00
|
|
|
Long accountId = UserContext.getUserHolder().getId();
|
2025-01-07 17:27:29 +08:00
|
|
|
String userEmail = accountService.getById(accountId).getUserEmail();
|
|
|
|
|
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)
|
|
|
|
|
|| accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)
|
2025-07-02 09:18:22 +08:00
|
|
|
|| userEmail.equals("joho8228@hotmail.com")
|
2025-06-19 17:39:18 +08:00
|
|
|
|| userEmail.equals("chelseayu@code-create.com.hk")
|
2025-01-07 17:27:29 +08:00
|
|
|
) {
|
2024-08-05 15:19:02 +08:00
|
|
|
return Response.success(convenientInquiryService.getTrial(queryUserConditionsVO));
|
|
|
|
|
} else {
|
2024-03-04 16:33:23 +08:00
|
|
|
return Response.fail("Sorry, you don't have permission");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取指定时间区间内所有用户design的使用情况")
|
|
|
|
|
@GetMapping("/getDesignStatistic")
|
2025-02-21 17:16:44 +08:00
|
|
|
public Response<List<UserDesignStatisticDTO>> getDesignStatistic(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,
|
2024-08-21 15:07:14 +08:00
|
|
|
@RequestParam(required = false) List<Long> ids, @RequestParam(required = false) String email) {
|
2024-03-04 16:33:23 +08:00
|
|
|
Long accountId = UserContext.getUserHolder().getId();
|
2025-01-08 09:50:13 +08:00
|
|
|
String userEmail = accountService.getById(accountId).getUserEmail();
|
|
|
|
|
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)
|
|
|
|
|
|| accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)
|
2025-07-02 09:18:22 +08:00
|
|
|
|| userEmail.equals("joho8228@hotmail.com")
|
2025-06-19 17:39:18 +08:00
|
|
|
|| userEmail.equals("chelseayu@code-create.com.hk")
|
2025-01-08 09:50:13 +08:00
|
|
|
) {
|
2024-04-22 13:09:44 +08:00
|
|
|
if (StringUtil.isNullOrEmpty(startTime)) startTime = "2024-02-01 00:00:00";
|
2024-08-05 15:19:02 +08:00
|
|
|
if (StringUtil.isNullOrEmpty(endTime)) {
|
2024-04-22 13:09:44 +08:00
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
endTime = simpleDateFormat.format(date);
|
|
|
|
|
}
|
2024-08-21 15:07:14 +08:00
|
|
|
if (!StringUtil.isNullOrEmpty(email)){
|
|
|
|
|
email = email.trim();
|
|
|
|
|
}
|
|
|
|
|
List<UserDesignStatisticDTO> designStatistic = designMapper.getDesignStatistic(startTime, endTime, ids, email);
|
2024-03-04 16:33:23 +08:00
|
|
|
return Response.success(designStatistic);
|
2024-08-05 15:19:02 +08:00
|
|
|
} else {
|
2024-03-04 16:33:23 +08:00
|
|
|
return Response.fail("Sorry, you don't have permission");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 17:24:14 +08:00
|
|
|
|
|
|
|
|
//调查问卷
|
|
|
|
|
@ApiOperation("获取调查问卷统计详情")
|
|
|
|
|
@GetMapping("/getQuestionnaireStatistic")
|
2024-08-05 15:19:02 +08:00
|
|
|
public Response<QuestionnaireFeedbackVO> getQuestionnaire() {
|
2024-07-29 17:24:14 +08:00
|
|
|
return Response.success(convenientInquiryService.getQuestionnaireInfo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取所有调查问卷")
|
|
|
|
|
@GetMapping("/getAllQuestionnaire")
|
2024-08-05 15:19:02 +08:00
|
|
|
public Response<List<QuestionnaireVO>> getAllQuestionnaire() {
|
2024-07-29 17:24:14 +08:00
|
|
|
return Response.success(convenientInquiryService.getAllQuestionnaire());
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 10:00:26 +08:00
|
|
|
@ApiOperation("获取近期新用户")
|
2024-08-06 11:29:33 +08:00
|
|
|
@PostMapping("/recentNewUser")
|
|
|
|
|
public Response<IPage<Account>> recentNewUser(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
|
|
|
|
return Response.success(convenientInquiryService.recentNewUser(queryUserConditionsVO));
|
2024-08-01 10:00:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取近期新用户图表数据")
|
2024-08-05 15:19:02 +08:00
|
|
|
@GetMapping("/recentNewUserChart")
|
2024-08-01 10:00:26 +08:00
|
|
|
public Response<Map<String, Object>> recentNewUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
2024-08-05 15:19:02 +08:00
|
|
|
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
2024-08-06 11:29:33 +08:00
|
|
|
@ApiParam("userType") @RequestParam Integer userType) {
|
2024-08-01 10:00:26 +08:00
|
|
|
return Response.success(convenientInquiryService.recentNewUserChart(startTime, endTime, userType));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取近期活跃用户")
|
2024-08-06 11:29:33 +08:00
|
|
|
@PostMapping("/recentActiveUser")
|
|
|
|
|
public Response<IPage<Account>> recentActiveUser(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
|
|
|
|
return Response.success(convenientInquiryService.recentActiveUser(queryUserConditionsVO));
|
2024-08-01 10:00:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取近期活跃用户图表数据")
|
2024-08-05 15:19:02 +08:00
|
|
|
@GetMapping("/recentActiveUserChart")
|
2024-08-01 10:00:26 +08:00
|
|
|
public Response<Integer> recentActiveUserChart(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
2024-08-05 15:19:02 +08:00
|
|
|
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime) {
|
2024-08-01 10:00:26 +08:00
|
|
|
return Response.success(convenientInquiryService.recentActiveUserChart(startTime, endTime));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取用户的各模块功能使用详情")
|
2024-08-05 15:19:02 +08:00
|
|
|
@GetMapping("/getActiveUserFunc")
|
2024-08-01 10:00:26 +08:00
|
|
|
public Response<Map<String, List<Object>>> getActiveUserFunc(@ApiParam(value = "startTime") @RequestParam @Nullable String startTime,
|
2024-08-05 15:19:02 +08:00
|
|
|
@ApiParam(value = "endTime") @RequestParam @Nullable String endTime,
|
|
|
|
|
@ApiParam("userIdList") @RequestParam @Nullable List<Long> userIdList) {
|
2024-08-01 10:00:26 +08:00
|
|
|
return Response.success(convenientInquiryService.getActiveUserFunc(startTime, endTime, userIdList));
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 15:19:02 +08:00
|
|
|
@ApiOperation("试用用户到正式用户的转化率")
|
|
|
|
|
@GetMapping("/conversionRate")
|
2024-11-06 17:51:51 +08:00
|
|
|
public Response<Map<String, Object>> conversionRate(@ApiParam(value = "startTime") @RequestParam(required = false) @Nullable String startTime,
|
|
|
|
|
@ApiParam(value = "endTime") @RequestParam(required = false) @Nullable String endTime) {
|
|
|
|
|
return Response.success(convenientInquiryService.conversionRate(startTime, endTime));
|
2024-08-05 15:19:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("试用用户国家/城市分布")
|
|
|
|
|
@GetMapping("/trialUserCountry")
|
2024-11-06 17:27:16 +08:00
|
|
|
public Response<Map<String, List<Object>>> trialUserCountry(@ApiParam(value = "startTime") @RequestParam(required = false) @Nullable String startTime,
|
|
|
|
|
@ApiParam(value = "endTime") @RequestParam(required = false) @Nullable String endTime) {
|
|
|
|
|
return Response.success(convenientInquiryService.trialUserCountry(startTime, endTime));
|
2024-08-05 15:19:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("添加用户")
|
|
|
|
|
@PostMapping("/addUser")
|
|
|
|
|
public Response<Boolean> addUser(@Valid @RequestBody AccountAddDTO accountAddDTO) {
|
2025-01-08 09:50:13 +08:00
|
|
|
Long userAccountId = UserContext.getUserHolder().getId();
|
2025-01-08 10:24:51 +08:00
|
|
|
if (userAccountId.equals(31L) || userAccountId.equals(87L) || userAccountId.equals(83L)
|
2025-01-08 09:50:13 +08:00
|
|
|
|| userAccountId.equals(6L) || userAccountId.equals(4L) || userAccountId.equals(73L)
|
|
|
|
|
) {
|
|
|
|
|
return Response.success(convenientInquiryService.addUser(accountAddDTO));
|
|
|
|
|
} else {
|
|
|
|
|
return Response.fail("Sorry, you don't have permission");
|
|
|
|
|
}
|
2024-08-05 15:19:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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) {
|
2025-01-08 09:50:13 +08:00
|
|
|
Long userAccountId = UserContext.getUserHolder().getId();
|
2025-01-08 10:24:51 +08:00
|
|
|
if (userAccountId.equals(31L) || userAccountId.equals(87L) || userAccountId.equals(83L)
|
2025-01-08 09:50:13 +08:00
|
|
|
|| userAccountId.equals(6L) || userAccountId.equals(4L) || userAccountId.equals(73L)
|
|
|
|
|
) {
|
|
|
|
|
return Response.success(convenientInquiryService.modifyUser(accountId, validEndTime, systemUser, credits));
|
|
|
|
|
} else {
|
|
|
|
|
return Response.fail("Sorry, you don't have permission");
|
|
|
|
|
}
|
2024-08-05 15:19:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取用户信息")
|
|
|
|
|
@PostMapping("/getUserInfo")
|
|
|
|
|
public Response<IPage<Account>> getUserInfo(@Valid @RequestBody QueryUserConditionsVO queryUserConditionsVO) {
|
|
|
|
|
Long accountId = UserContext.getUserHolder().getId();
|
2025-01-08 09:50:13 +08:00
|
|
|
String userEmail = accountService.getById(accountId).getUserEmail();
|
|
|
|
|
if (accountId.equals(31L) || accountId.equals(87L) || accountId.equals(83L)
|
|
|
|
|
|| accountId.equals(6L) || accountId.equals(4L) || accountId.equals(73L)
|
2025-07-02 09:18:22 +08:00
|
|
|
|| userEmail.equals("joho8228@hotmail.com")
|
2025-06-19 17:39:18 +08:00
|
|
|
|| userEmail.equals("chelseayu@code-create.com.hk")
|
2025-01-08 09:50:13 +08:00
|
|
|
) {
|
2024-08-05 15:19:02 +08:00
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 13:27:27 +08:00
|
|
|
@ApiOperation("获取所有交易信息")
|
|
|
|
|
@PostMapping("/queryTransaction")
|
|
|
|
|
public Response<PageBaseResponse<PaymentInfoVO>> queryTransactionRecords(@Valid @RequestBody QueryPaymentInfoDTO queryPaymentInfoDTO){
|
|
|
|
|
return Response.success(convenientInquiryService.queryTransactionRecords(queryPaymentInfoDTO));
|
|
|
|
|
}
|
2025-01-10 16:13:45 +08:00
|
|
|
|
|
|
|
|
@ApiOperation("获取所有国家、城市")
|
|
|
|
|
@GetMapping("/getCities")
|
|
|
|
|
public Response<Map<String, List<String>>> getCities(){
|
|
|
|
|
return Response.success(convenientInquiryService.getCities());
|
|
|
|
|
}
|
2025-01-24 13:26:53 +08:00
|
|
|
|
|
|
|
|
@ApiOperation("下载交易记录")
|
2025-01-27 16:39:19 +08:00
|
|
|
@PostMapping("/queryTransaction/download")
|
|
|
|
|
public Response<String> exportTransactionRecords(@Valid @RequestBody QueryPaymentInfoDTO queryPaymentInfoDTO, HttpServletResponse response){
|
|
|
|
|
return Response.success(convenientInquiryService.exportTransactionRecords(queryPaymentInfoDTO, response));
|
2025-01-24 13:26:53 +08:00
|
|
|
}
|
2024-03-04 16:33:23 +08:00
|
|
|
}
|