|
|
@ -28,6 +28,7 @@ import com.example.demo.domain.vo.coin.*; |
|
|
|
|
|
|
|
|
import com.example.demo.mapper.coin.ExportMapper; |
|
|
import com.example.demo.mapper.coin.ExportMapper; |
|
|
import com.example.demo.mapper.coin.MarketMapper; |
|
|
import com.example.demo.mapper.coin.MarketMapper; |
|
|
|
|
|
import com.example.demo.service.cash.CashCollectionService; |
|
|
import com.example.demo.service.coin.ExportExcelService; |
|
|
import com.example.demo.service.coin.ExportExcelService; |
|
|
import com.example.demo.service.coin.MarketService; |
|
|
import com.example.demo.service.coin.MarketService; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
@ -91,6 +92,8 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
private ExportMapper exportMapper; |
|
|
private ExportMapper exportMapper; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private MarketService marketService; |
|
|
private MarketService marketService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private CashCollectionService cashCollectionService; |
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Transactional |
|
|
@Override |
|
|
@Override |
|
|
@ -527,6 +530,74 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
|
@Override |
|
|
|
|
|
public Exception UserWalletExcel(String message) throws Exception { |
|
|
|
|
|
return exportExcelGeneric(message, "userWallet", page -> { |
|
|
|
|
|
try { |
|
|
|
|
|
JsonNode rootNode = objectMapper.readTree(message); |
|
|
|
|
|
JsonNode requestDataNode = rootNode.path("requestData"); |
|
|
|
|
|
JsonNode userWalletDTONode = requestDataNode.path("userWalletDTO"); |
|
|
|
|
|
|
|
|
|
|
|
// 解析查询参数 |
|
|
|
|
|
Integer jwcode = null; |
|
|
|
|
|
String market = null; |
|
|
|
|
|
Integer pageNum = userWalletDTONode.path("page").asInt(1); |
|
|
|
|
|
Integer pageSize = userWalletDTONode.path("pageSize").asInt(20); |
|
|
|
|
|
|
|
|
|
|
|
if (!userWalletDTONode.path("jwcode").isMissingNode()) { |
|
|
|
|
|
jwcode = userWalletDTONode.path("jwcode").asInt(); |
|
|
|
|
|
} |
|
|
|
|
|
if (!userWalletDTONode.path("market").isMissingNode()) { |
|
|
|
|
|
market = userWalletDTONode.path("market").asText(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 从请求数据中获取语言设置 |
|
|
|
|
|
String lang = "zh_CN"; |
|
|
|
|
|
JsonNode langNode = rootNode.path("lang"); |
|
|
|
|
|
if (langNode != null && !langNode.asText().isEmpty()) { |
|
|
|
|
|
lang = langNode.asText(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 调用查询接口 |
|
|
|
|
|
PageInfo<UserWalletVO> result = cashCollectionService.selectUserWallets(jwcode, market, pageNum, pageSize); |
|
|
|
|
|
|
|
|
|
|
|
// 翻译处理并将数据扁平化(一个用户多个钱包要拆分成多行) |
|
|
|
|
|
List<UserWalletVO> flatList = new ArrayList<>(); |
|
|
|
|
|
if (result != null && result.getList() != null) { |
|
|
|
|
|
translateUserWalletList((List<UserWalletVO>) result.getList(), lang); |
|
|
|
|
|
|
|
|
|
|
|
// 将嵌套结构转换为扁平列表(每个钱包作为一行) |
|
|
|
|
|
for (UserWalletVO vo : result.getList()) { |
|
|
|
|
|
if (vo.getWalletList() != null && !vo.getWalletList().isEmpty()) { |
|
|
|
|
|
// 为每个钱包创建一个独立的 UserWalletVO 对象 |
|
|
|
|
|
for (WalletItem wallet : vo.getWalletList()) { |
|
|
|
|
|
UserWalletVO flatVO = new UserWalletVO(); |
|
|
|
|
|
flatVO.setJwcode(vo.getJwcode()); |
|
|
|
|
|
flatVO.setUserName(vo.getUserName()); |
|
|
|
|
|
flatVO.setMarketName(vo.getMarketName()); |
|
|
|
|
|
flatVO.setWalletId(wallet.getWalletId()); |
|
|
|
|
|
flatVO.setWalletName(wallet.getWalletName()); |
|
|
|
|
|
flatVO.setCurrentPermanentGold(wallet.getCurrentPermanentGold()); |
|
|
|
|
|
flatList.add(flatVO); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果没有钱包,也保留该用户记录 |
|
|
|
|
|
flatList.add(vo); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 更新分页信息的 list 为扁平化后的列表 |
|
|
|
|
|
result.setList(flatList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Result.success(result); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<Export> getExcel(Export export) { |
|
|
public List<Export> getExcel(Export export) { |
|
|
List<Export> list = exportMapper.getExportRecord(export.getAccount(),export.getType()); |
|
|
List<Export> list = exportMapper.getExportRecord(export.getAccount(),export.getType()); |
|
|
@ -897,6 +968,26 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
.head(head) |
|
|
.head(head) |
|
|
.build(); |
|
|
.build(); |
|
|
} |
|
|
} |
|
|
|
|
|
// 如果是用户钱包余额表,添加动态表头处理器 |
|
|
|
|
|
else if ("userWallet".equals(exportType)) { |
|
|
|
|
|
Map<String, String> headers = excelHeaderTranslator.getUserWalletBalanceHeaders(lang); |
|
|
|
|
|
List<String> columnOrder = excelHeaderTranslator.getUserWalletBalanceColumnOrder(); |
|
|
|
|
|
|
|
|
|
|
|
// 构建自定义表头 |
|
|
|
|
|
List<List<String>> head = new ArrayList<>(); |
|
|
|
|
|
for (String fieldName : columnOrder) { |
|
|
|
|
|
String headerText = headers.get(fieldName); |
|
|
|
|
|
if (headerText != null) { |
|
|
|
|
|
List<String> headItems = new ArrayList<>(); |
|
|
|
|
|
headItems.add(headerText); |
|
|
|
|
|
head.add(headItems); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
writeSheet = EasyExcel.writerSheet("Sheet1") |
|
|
|
|
|
.head(head) |
|
|
|
|
|
.build(); |
|
|
|
|
|
} |
|
|
else { |
|
|
else { |
|
|
writeSheet = EasyExcel.writerSheet("Sheet1").build(); |
|
|
writeSheet = EasyExcel.writerSheet("Sheet1").build(); |
|
|
} |
|
|
} |
|
|
@ -1171,6 +1262,8 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
return FundsDTO.class; |
|
|
return FundsDTO.class; |
|
|
case "userWalletRecord": |
|
|
case "userWalletRecord": |
|
|
return UserWalletRecordVO.class; |
|
|
return UserWalletRecordVO.class; |
|
|
|
|
|
case "userWallet": |
|
|
|
|
|
return UserWalletVO.class; |
|
|
default: |
|
|
default: |
|
|
throw new IllegalArgumentException("不支持的导出类型: " + exportType); |
|
|
throw new IllegalArgumentException("不支持的导出类型: " + exportType); |
|
|
} |
|
|
} |
|
|
@ -1944,4 +2037,29 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 翻译用户钱包列表 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void translateUserWalletList(List<UserWalletVO> list, String lang) { |
|
|
|
|
|
if (list == null || list.isEmpty() || "zh_CN".equalsIgnoreCase(lang) || "zh".equalsIgnoreCase(lang)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (UserWalletVO item : list) { |
|
|
|
|
|
// 翻译地区名称 |
|
|
|
|
|
if (item.getMarketName() != null && !item.getMarketName().isEmpty()) { |
|
|
|
|
|
item.setMarketName(languageTranslationUtil.translate(item.getMarketName(), lang)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 翻译钱包名称 |
|
|
|
|
|
if (item.getWalletList() != null) { |
|
|
|
|
|
for (WalletItem wallet : item.getWalletList()) { |
|
|
|
|
|
if (wallet.getWalletName() != null && !wallet.getWalletName().isEmpty()) { |
|
|
|
|
|
wallet.setWalletName(languageTranslationUtil.translate(wallet.getWalletName(), lang)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |