|
@@ -10,16 +10,20 @@ import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import shop.alien.entity.store.*;
|
|
import shop.alien.entity.store.*;
|
|
|
import shop.alien.entity.store.vo.ManagementInfoVo;
|
|
import shop.alien.entity.store.vo.ManagementInfoVo;
|
|
|
import shop.alien.mapper.*;
|
|
import shop.alien.mapper.*;
|
|
|
import shop.alien.store.service.ManagementInfoService;
|
|
import shop.alien.store.service.ManagementInfoService;
|
|
|
-
|
|
|
|
|
-import java.io.File;
|
|
|
|
|
-import java.io.FileInputStream;
|
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
|
|
+import shop.alien.util.ali.AliOSSUtil;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.*;
|
|
|
|
|
+import java.net.HttpURLConnection;
|
|
|
|
|
+import java.net.URL;
|
|
|
|
|
+import java.nio.file.Files;
|
|
|
|
|
+import java.nio.file.Path;
|
|
|
|
|
+import java.nio.file.StandardCopyOption;
|
|
|
import java.text.DateFormat;
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.*;
|
|
import java.time.*;
|
|
@@ -53,6 +57,8 @@ public class ManagementInfoServiceImpl implements ManagementInfoService {
|
|
|
|
|
|
|
|
private final StoreUserMapper storeUserMapper;
|
|
private final StoreUserMapper storeUserMapper;
|
|
|
|
|
|
|
|
|
|
+ private final AliOSSUtil aliOSSUtil;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<ManagementInfo> getAllManagementInfo(int pageNo, int pageSize, String storeName) {
|
|
public IPage<ManagementInfo> getAllManagementInfo(int pageNo, int pageSize, String storeName) {
|
|
|
IPage<LifeDiscountCoupon> iPage = new Page<>(pageNo, pageSize);
|
|
IPage<LifeDiscountCoupon> iPage = new Page<>(pageNo, pageSize);
|
|
@@ -75,6 +81,7 @@ public class ManagementInfoServiceImpl implements ManagementInfoService {
|
|
|
for (StoreIncomeDetailsRecord storeIncomeDetailsRecord : storeIncomeDetailsRecords) {
|
|
for (StoreIncomeDetailsRecord storeIncomeDetailsRecord : storeIncomeDetailsRecords) {
|
|
|
storeIncomeDetailsCount += storeIncomeDetailsRecord.getMoney();
|
|
storeIncomeDetailsCount += storeIncomeDetailsRecord.getMoney();
|
|
|
}
|
|
}
|
|
|
|
|
+ storeIncomeDetailsCount = Math.floor(storeIncomeDetailsCount/1000000*100)/100;
|
|
|
managementInfo.setAccountFrozen(storeIncomeDetailsCount);
|
|
managementInfo.setAccountFrozen(storeIncomeDetailsCount);
|
|
|
}
|
|
}
|
|
|
return allManagementInfo;
|
|
return allManagementInfo;
|
|
@@ -113,38 +120,54 @@ public class ManagementInfoServiceImpl implements ManagementInfoService {
|
|
|
ManagementInfoVo allWrittenOffAmount = managementInfoMapper.getAllWrittenOffAmount(startDate, endDate, null);
|
|
ManagementInfoVo allWrittenOffAmount = managementInfoMapper.getAllWrittenOffAmount(startDate, endDate, null);
|
|
|
//查询总提现金额
|
|
//查询总提现金额
|
|
|
ManagementInfoVo totalWithdrawalAmount = managementInfoMapper.getTotalWithdrawalAmount(startDate, endDate, null);
|
|
ManagementInfoVo totalWithdrawalAmount = managementInfoMapper.getTotalWithdrawalAmount(startDate, endDate, null);
|
|
|
- //查询已解冻金额
|
|
|
|
|
|
|
+ //查询已提现金额(根据时间查询)
|
|
|
|
|
+ ManagementInfoVo withdrawalAmount = managementInfoMapper.getWithdrawalAmount(startDate, endDate, null);
|
|
|
|
|
+ //查询总订单金额(根据时间查询)
|
|
|
|
|
+ ManagementInfoVo orderAmount = managementInfoMapper.getOrderAmount(startDate, endDate, null);
|
|
|
|
|
+ //查询总交易金额(根据时间查询)
|
|
|
|
|
+ ManagementInfoVo transactionAmount = managementInfoMapper.getTransactionAmount(startDate, endDate, null);
|
|
|
|
|
+ //查询总核销金额(根据时间查询)
|
|
|
|
|
+ ManagementInfoVo writtenOffAmount = managementInfoMapper.getWrittenOffAmount(startDate, endDate, null);
|
|
|
|
|
+
|
|
|
|
|
+ //查询已冻结金额
|
|
|
List<StoreIncomeDetailsRecord> storeIncomeDetailsRecords = storeIncomeDetailsRecordMapper
|
|
List<StoreIncomeDetailsRecord> storeIncomeDetailsRecords = storeIncomeDetailsRecordMapper
|
|
|
.selectList(
|
|
.selectList(
|
|
|
new LambdaQueryWrapper<StoreIncomeDetailsRecord>()
|
|
new LambdaQueryWrapper<StoreIncomeDetailsRecord>()
|
|
|
.gt(StoreIncomeDetailsRecord::getCreatedTime, threeDaysAgoMidnight)
|
|
.gt(StoreIncomeDetailsRecord::getCreatedTime, threeDaysAgoMidnight)
|
|
|
|
|
+ .gt(StoreIncomeDetailsRecord::getCreatedTime, startDate)
|
|
|
|
|
+ .lt(StoreIncomeDetailsRecord::getCreatedTime, endDate)
|
|
|
);
|
|
);
|
|
|
Double storeIncomeDetailsCount = 0d;
|
|
Double storeIncomeDetailsCount = 0d;
|
|
|
for (StoreIncomeDetailsRecord storeIncomeDetailsRecord : storeIncomeDetailsRecords) {
|
|
for (StoreIncomeDetailsRecord storeIncomeDetailsRecord : storeIncomeDetailsRecords) {
|
|
|
storeIncomeDetailsCount += storeIncomeDetailsRecord.getMoney();
|
|
storeIncomeDetailsCount += storeIncomeDetailsRecord.getMoney();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
//存入账单排名
|
|
//存入账单排名
|
|
|
result.put("billingRanking", billingRanking);
|
|
result.put("billingRanking", billingRanking);
|
|
|
//存入已付款金额
|
|
//存入已付款金额
|
|
|
- result.put("amountPaid", amountPaid.getAmountPaid());
|
|
|
|
|
- //存入总交易金额
|
|
|
|
|
- result.put("totalTransactionAmount", totalTransactionAmount.getTotalTransactionAmount());
|
|
|
|
|
- //存入交易笔数
|
|
|
|
|
- result.put("transactionNumber", transactionNumber.getTransactionNumber());
|
|
|
|
|
|
|
+ result.put("amountPaid", Math.floor(amountPaid.getAmountPaid()/10000*100)/100);
|
|
|
|
|
+
|
|
|
|
|
+ //存入冻结未提现金额
|
|
|
|
|
+ result.put("unwithdrawnAmountsFrozen", Math.floor((withdrawalAmount.getTotalWithdrawalAmount() - storeIncomeDetailsCount)/10000*100)/100);
|
|
|
|
|
+ //存入未解冻金额
|
|
|
|
|
+ result.put("freezeAmounts", Math.floor(storeIncomeDetailsCount/10000*100)/100);
|
|
|
|
|
+ // 已提现金额
|
|
|
|
|
+ result.put("withdrawalAmount", Math.floor(withdrawalAmount.getTotalWithdrawalAmount()/10000*100)/100);
|
|
|
//存入未核销金额
|
|
//存入未核销金额
|
|
|
- result.put("amountNotWrittenOff", allOrderAmount.getAllOrderAmount() - allWrittenOffAmount.getAllWrittenOffAmount());
|
|
|
|
|
|
|
+ result.put("amountNotWrittenOff", Math.floor((orderAmount.getAllOrderAmount() - writtenOffAmount.getAllWrittenOffAmount())/10000*100)/100);
|
|
|
|
|
+ //存入交易笔数
|
|
|
|
|
+ result.put("transactionNumber", Math.floor(transactionNumber.getTransactionNumber()/10000*100)/100);
|
|
|
//存入已核销金额
|
|
//存入已核销金额
|
|
|
- result.put("amountWrittenOff", allWrittenOffAmount.getAllWrittenOffAmount());
|
|
|
|
|
- //存入已冻结未提现金额
|
|
|
|
|
- result.put("unwithdrawnAmountsFrozen", totalWithdrawalAmount.getTotalWithdrawalAmount() - storeIncomeDetailsCount);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ result.put("amountWrittenOff", Math.floor(writtenOffAmount.getAllWrittenOffAmount()/10000*100)/100);
|
|
|
|
|
+ //存入总交易金额
|
|
|
|
|
+ result.put("totalTransactionAmount", Math.floor(transactionAmount.getTotalTransactionAmount()/10000*100)/100);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public IPage<ManagementInfoVo> getStoreOrderDetail(int pageNo, int pageSize, String storeId) {
|
|
|
|
|
|
|
+ public IPage<ManagementInfoVo> getStoreOrderDetail(int pageNo, int pageSize, String storeId, String orderNo, String userId, String userName) {
|
|
|
IPage<ManagementInfoVo> iPage = new Page<>(pageNo, pageSize);
|
|
IPage<ManagementInfoVo> iPage = new Page<>(pageNo, pageSize);
|
|
|
- IPage<ManagementInfoVo> storeOrderDetail = managementInfoMapper.getStoreOrderDetail(iPage, storeId);
|
|
|
|
|
|
|
+ IPage<ManagementInfoVo> storeOrderDetail = managementInfoMapper.getStoreOrderDetail(iPage, storeId, orderNo, userId, userName);
|
|
|
return storeOrderDetail;
|
|
return storeOrderDetail;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -157,6 +180,13 @@ public class ManagementInfoServiceImpl implements ManagementInfoService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public HashMap<String, Object> storeDetailBillingStatistics(String storeId) {
|
|
public HashMap<String, Object> storeDetailBillingStatistics(String storeId) {
|
|
|
|
|
+ // 获取当前日期
|
|
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
|
|
+ // 计算三天前的日期
|
|
|
|
|
+ LocalDate threeDaysAgo = currentDate.minusDays(3);
|
|
|
|
|
+ // 设置时间为当天的 0 点
|
|
|
|
|
+ LocalDateTime threeDaysAgoMidnight = threeDaysAgo.atStartOfDay();
|
|
|
|
|
+
|
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
HashMap<String, Object> result = new HashMap<>();
|
|
|
//查询总交易金额
|
|
//查询总交易金额
|
|
|
ManagementInfoVo allOrderAmount = managementInfoMapper.getAllOrderAmount(null, null, storeId);
|
|
ManagementInfoVo allOrderAmount = managementInfoMapper.getAllOrderAmount(null, null, storeId);
|
|
@@ -167,15 +197,39 @@ public class ManagementInfoServiceImpl implements ManagementInfoService {
|
|
|
//查询核验金额
|
|
//查询核验金额
|
|
|
ManagementInfoVo verificationAmount = managementInfoMapper.getVerificationAmount(storeId);
|
|
ManagementInfoVo verificationAmount = managementInfoMapper.getVerificationAmount(storeId);
|
|
|
|
|
|
|
|
|
|
+ //查询已提现金额
|
|
|
|
|
+ ManagementInfoVo totalWithdrawalAmount = managementInfoMapper.getTotalWithdrawalAmount(null, null, storeId);
|
|
|
|
|
+
|
|
|
|
|
+ //查询冻结金额
|
|
|
|
|
+ List<StoreIncomeDetailsRecord> storeIncomeDetailsRecords = storeIncomeDetailsRecordMapper
|
|
|
|
|
+ .selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<StoreIncomeDetailsRecord>()
|
|
|
|
|
+ .gt(StoreIncomeDetailsRecord::getCreatedTime, threeDaysAgoMidnight)
|
|
|
|
|
+ .eq(StoreIncomeDetailsRecord::getStoreId, storeId)
|
|
|
|
|
+ );
|
|
|
|
|
+ Double storeIncomeDetailsCount = 0d;
|
|
|
|
|
+ for (StoreIncomeDetailsRecord storeIncomeDetailsRecord : storeIncomeDetailsRecords) {
|
|
|
|
|
+ storeIncomeDetailsCount += storeIncomeDetailsRecord.getMoney();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//存入已付款金额
|
|
//存入已付款金额
|
|
|
- result.put("allOrderAmount", allOrderAmount.getAllOrderAmount());
|
|
|
|
|
|
|
+ result.put("allOrderAmount", Math.floor(allOrderAmount.getAllOrderAmount()/10000*100)/100);
|
|
|
//存入总交易金额
|
|
//存入总交易金额
|
|
|
result.put("userCount", userCount.getUserCount());
|
|
result.put("userCount", userCount.getUserCount());
|
|
|
//存入交易笔数
|
|
//存入交易笔数
|
|
|
- result.put("orderTransactionNumber", orderTransactionNumber.getOrderTransactionNumber());
|
|
|
|
|
- //存入交易笔数
|
|
|
|
|
- result.put("verificationAmount", verificationAmount.getVerificationAmount());
|
|
|
|
|
|
|
+ result.put("orderTransactionNumber", Math.floor(orderTransactionNumber.getOrderTransactionNumber()/10000*100)/100);
|
|
|
|
|
+ //存入核验金额
|
|
|
|
|
+ result.put("verificationAmount", Math.floor(verificationAmount.getVerificationAmount()/10000*100)/100);
|
|
|
|
|
+
|
|
|
|
|
+ //已提现金额
|
|
|
|
|
+ result.put("totalWithdrawalAmount", Math.floor(totalWithdrawalAmount.getTotalWithdrawalAmount()/10000*100)/100);
|
|
|
|
|
|
|
|
|
|
+ //冻结金额
|
|
|
|
|
+ result.put("freezeAmounts", Math.floor(storeIncomeDetailsCount/10000*100)/100);
|
|
|
|
|
+
|
|
|
|
|
+ //冻结待提现金额
|
|
|
|
|
+ result.put("unwithdrawnAmountsFrozen", Math.floor(storeIncomeDetailsCount/10000*100)/100);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -504,7 +558,16 @@ public class ManagementInfoServiceImpl implements ManagementInfoService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String generateReceiptFile(String storeName, String storeAccount, String storePhone, String invoiceAmount, String amountPaid, String paymentTime, String fileName) {
|
|
public String generateReceiptFile(String storeName, String storeAccount, String storePhone, String invoiceAmount, String amountPaid, String paymentTime, String fileName) {
|
|
|
- String filePath = "";
|
|
|
|
|
|
|
+ String filePath = excelPath + excelGeneratePath + fileName + ".xlsx";
|
|
|
|
|
+ String osName = System.getProperty("os.name").toLowerCase();
|
|
|
|
|
+ if (osName.contains("win")) {
|
|
|
|
|
+ filePath = "d:/" + filePath;
|
|
|
|
|
+ String substring = filePath.substring(0, filePath.lastIndexOf("/"));
|
|
|
|
|
+ File dir = new File(substring);
|
|
|
|
|
+ if (!dir.exists()) {
|
|
|
|
|
+ dir.mkdirs();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
// 创建 File 对象
|
|
// 创建 File 对象
|
|
|
File file = new File(excelPath + excelGeneratePath + fileName + ".xlsx");
|
|
File file = new File(excelPath + excelGeneratePath + fileName + ".xlsx");
|
|
|
// 判断文件是否存在
|
|
// 判断文件是否存在
|
|
@@ -512,8 +575,8 @@ public class ManagementInfoServiceImpl implements ManagementInfoService {
|
|
|
filePath = fileUrl + "excel" + excelGeneratePath + fileName + ".xlsx";
|
|
filePath = fileUrl + "excel" + excelGeneratePath + fileName + ".xlsx";
|
|
|
return filePath;
|
|
return filePath;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- try (FileInputStream fis = new FileInputStream(excelPath + excelClearingReceipt);
|
|
|
|
|
|
|
+ String templateUrl = fileUrl +"excel/" +excelClearingReceipt;
|
|
|
|
|
+ try (FileInputStream fis = toFileInputStream(downloadAsInputStream(templateUrl));
|
|
|
Workbook workbook = new XSSFWorkbook(fis)) {
|
|
Workbook workbook = new XSSFWorkbook(fis)) {
|
|
|
// 获取第一个工作表
|
|
// 获取第一个工作表
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
@@ -581,14 +644,41 @@ public class ManagementInfoServiceImpl implements ManagementInfoService {
|
|
|
sheet.autoSizeColumn(i);
|
|
sheet.autoSizeColumn(i);
|
|
|
}
|
|
}
|
|
|
// 保存填充后的工作簿到本地文件
|
|
// 保存填充后的工作簿到本地文件
|
|
|
- try (FileOutputStream fos = new FileOutputStream(excelPath + excelGeneratePath + fileName + ".xlsx")) {
|
|
|
|
|
|
|
+// try (FileOutputStream fos = new FileOutputStream(excelPath + excelGeneratePath + fileName + ".xlsx")) {
|
|
|
|
|
+// workbook.write(fos);
|
|
|
|
|
+// filePath = fileUrl + "excel" + excelGeneratePath + fileName + ".xlsx";
|
|
|
|
|
+// }
|
|
|
|
|
+ try (FileOutputStream fos = new FileOutputStream(filePath)) {
|
|
|
workbook.write(fos);
|
|
workbook.write(fos);
|
|
|
- filePath = fileUrl + "excel" + excelGeneratePath + fileName + ".xlsx";
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
- return filePath;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return aliOSSUtil.uploadFile(new File(filePath), "excel/" + fileName + ".xlsx");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public InputStream downloadAsInputStream(String fileUrl) throws IOException {
|
|
|
|
|
+ URL url = new URL(fileUrl);
|
|
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
|
|
+ connection.setRequestMethod("GET");
|
|
|
|
|
+ return connection.getInputStream(); // 直接返回 HTTP 流
|
|
|
|
|
+ }
|
|
|
|
|
+ public static FileInputStream toFileInputStream(InputStream inputStream) throws IOException {
|
|
|
|
|
+ Path tempFile = Files.createTempFile("temp-", ".tmp");
|
|
|
|
|
+ tempFile.toFile().deleteOnExit();
|
|
|
|
|
+ try (InputStream is = inputStream) {
|
|
|
|
|
+ Files.copy(is, tempFile, StandardCopyOption.REPLACE_EXISTING);
|
|
|
|
|
+ }
|
|
|
|
|
+ return new FileInputStream(tempFile.toFile());
|
|
|
|
|
+ }
|
|
|
|
|
+ public FileInputStream getExcelTemplate() throws IOException {
|
|
|
|
|
+ // 1. 通过 ClassPathResource 获取文件
|
|
|
|
|
+ ClassPathResource resource = new ClassPathResource("templates/clearing_receipt.xlsx");
|
|
|
|
|
+ // 2. 转换为 FileInputStream(仅在文件系统有效,JAR 内会报错)
|
|
|
|
|
+ File file = resource.getFile(); // 注意:JAR 中会抛出 FileNotFoundException
|
|
|
|
|
+ return new FileInputStream(file);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// public static void main(String[] args) {
|
|
// public static void main(String[] args) {
|