|
|
|
|
@@ -7,6 +7,7 @@ import com.ai.da.common.enums.CreditsEventsEnum;
|
|
|
|
|
import com.ai.da.common.response.PageBaseResponse;
|
|
|
|
|
import com.ai.da.common.utils.CopyUtil;
|
|
|
|
|
import com.ai.da.common.utils.DateUtil;
|
|
|
|
|
import com.ai.da.common.utils.MinioUtil;
|
|
|
|
|
import com.ai.da.mapper.primary.*;
|
|
|
|
|
import com.ai.da.mapper.primary.entity.Account;
|
|
|
|
|
import com.ai.da.mapper.primary.entity.Questionnaire;
|
|
|
|
|
@@ -17,15 +18,21 @@ import com.ai.da.model.enums.Language;
|
|
|
|
|
import com.ai.da.model.vo.*;
|
|
|
|
|
import com.ai.da.service.*;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
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.minio.GetPresignedObjectUrlArgs;
|
|
|
|
|
import io.minio.MinioClient;
|
|
|
|
|
import io.minio.PutObjectArgs;
|
|
|
|
|
import io.minio.errors.*;
|
|
|
|
|
import io.minio.http.Method;
|
|
|
|
|
import io.netty.util.internal.StringUtil;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
@@ -34,7 +41,8 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.security.InvalidKeyException;
|
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
@@ -63,6 +71,9 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
|
|
|
|
@Resource
|
|
|
|
|
private PaymentInfoMapper paymentInfoMapper;
|
|
|
|
|
|
|
|
|
|
@Value("${minio.bucketName.users}")
|
|
|
|
|
private String userBucket;
|
|
|
|
|
|
|
|
|
|
public IPage<TrialOrder> getTrial(QueryUserConditionsVO queryUserConditionsVO) {
|
|
|
|
|
log.info("getTrial parameter : {},page:{}, size:{}", queryUserConditionsVO, queryUserConditionsVO.getPage(), queryUserConditionsVO.getSize());
|
|
|
|
|
/* 添加按条件查询试用用户 */
|
|
|
|
|
@@ -630,8 +641,8 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
|
|
|
|
}};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void exportTransactionRecords(String params, HttpServletResponse response){
|
|
|
|
|
QueryPaymentInfoDTO queryPaymentInfoDTO = JSONObject.parseObject(params, QueryPaymentInfoDTO.class);
|
|
|
|
|
public String exportTransactionRecords(QueryPaymentInfoDTO queryPaymentInfoDTO, HttpServletResponse response){
|
|
|
|
|
// QueryPaymentInfoDTO queryPaymentInfoDTO = JSONObject.parseObject(params, QueryPaymentInfoDTO.class);
|
|
|
|
|
|
|
|
|
|
// 查询数据总量
|
|
|
|
|
Long total = paymentInfoMapper.queryPaymentInfoCount(queryPaymentInfoDTO.getPlatform(), queryPaymentInfoDTO.getPayerTotal(),
|
|
|
|
|
@@ -643,13 +654,20 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
|
|
|
|
queryPaymentInfoDTO.getCountry(), queryPaymentInfoDTO.getCity(),
|
|
|
|
|
queryPaymentInfoDTO.getStartTime(), queryPaymentInfoDTO.getEndTime(),
|
|
|
|
|
total.intValue(), 0, "ASC", queryPaymentInfoDTO.getPayer());
|
|
|
|
|
excelExport(paymentInfoVOS, response);
|
|
|
|
|
try {
|
|
|
|
|
return excelExport(paymentInfoVOS, response);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void excelExport(List<PaymentInfoVO> paymentInfoVOS, HttpServletResponse response) {
|
|
|
|
|
@Resource
|
|
|
|
|
private MinioClient minioClient;
|
|
|
|
|
|
|
|
|
|
public String excelExport(List<PaymentInfoVO> paymentInfoVOS, HttpServletResponse response) throws IOException {
|
|
|
|
|
if (paymentInfoVOS == null || paymentInfoVOS.isEmpty()) {
|
|
|
|
|
log.info("无数据,直接返回,不生成空文件");
|
|
|
|
|
return;
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 文件名称
|
|
|
|
|
@@ -729,8 +747,8 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 将workBook转换为字节数组
|
|
|
|
|
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
|
|
|
|
// 将workBook转换为字节数组 直接以文件流的形式返回
|
|
|
|
|
/*try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
|
|
|
|
workBook.write(byteArrayOutputStream);
|
|
|
|
|
byte[] bytes = byteArrayOutputStream.toByteArray();
|
|
|
|
|
|
|
|
|
|
@@ -743,10 +761,46 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
|
|
|
|
responseOut.write(bytes);
|
|
|
|
|
responseOut.flush();
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
String filePath = UserContext.getUserHolder().getId() + "/transactionDownload" + "/" + fileName;
|
|
|
|
|
// 将workBook转换为字节数组
|
|
|
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
|
|
workBook.write(byteArrayOutputStream);
|
|
|
|
|
byte[] bytes = byteArrayOutputStream.toByteArray();
|
|
|
|
|
|
|
|
|
|
// 上传到 MinIO
|
|
|
|
|
try (InputStream inputStream = new ByteArrayInputStream(bytes)) {
|
|
|
|
|
try {
|
|
|
|
|
minioClient.putObject(PutObjectArgs.builder()
|
|
|
|
|
.bucket(userBucket)
|
|
|
|
|
.object(filePath)
|
|
|
|
|
.stream(inputStream, bytes.length, -1)
|
|
|
|
|
.contentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
|
|
|
|
.build());
|
|
|
|
|
} catch (InvalidKeyException | NoSuchAlgorithmException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
} catch (MinioException e) {
|
|
|
|
|
log.error("文件上传失败: " + e);
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.info("文件下载失败:{}", e.getMessage());
|
|
|
|
|
throw new BusinessException("文件下载失败");
|
|
|
|
|
|
|
|
|
|
// 获取下载链接
|
|
|
|
|
String downloadUrl = null;
|
|
|
|
|
try {
|
|
|
|
|
downloadUrl = minioClient.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
|
|
|
|
|
.bucket(userBucket)
|
|
|
|
|
.object(filePath)
|
|
|
|
|
.method(Method.GET)
|
|
|
|
|
.expiry(60 * 60 * 24) // 设置链接有效期为24小时
|
|
|
|
|
.build());
|
|
|
|
|
} catch (ErrorResponseException | InsufficientDataException | InternalException | InvalidKeyException |
|
|
|
|
|
InvalidResponseException | NoSuchAlgorithmException | XmlParserException | ServerException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return downloadUrl; // 返回下载链接
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|