|
|
@ -29,7 +29,9 @@ import com.example.demo.domain.vo.cash.PerformanceVO; |
|
|
import com.example.demo.domain.vo.coin.*; |
|
|
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.service.coin.ExportExcelService; |
|
|
import com.example.demo.service.coin.ExportExcelService; |
|
|
|
|
|
import com.example.demo.service.coin.MarketService; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
|
|
|
|
|
@ -43,6 +45,7 @@ import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.security.authentication.AuthenticationManager; |
|
|
import org.springframework.security.authentication.AuthenticationManager; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
import java.io.*; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
@ -88,6 +91,8 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
private static final int PAGE_SIZE = 5000; |
|
|
private static final int PAGE_SIZE = 5000; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ExportMapper exportMapper; |
|
|
private ExportMapper exportMapper; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private MarketService marketService; |
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Transactional |
|
|
@Override |
|
|
@Override |
|
|
@ -352,8 +357,36 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
JsonNode rootNode = objectMapper.readTree(message); |
|
|
JsonNode rootNode = objectMapper.readTree(message); |
|
|
JsonNode requestDataNode = rootNode.path("requestData"); |
|
|
JsonNode requestDataNode = rootNode.path("requestData"); |
|
|
JsonNode beanRechargeNode = requestDataNode.path("cashRecordDTO"); |
|
|
JsonNode beanRechargeNode = requestDataNode.path("cashRecordDTO"); |
|
|
|
|
|
String token = rootNode.path("token").asText(); |
|
|
CashRecordDTO cashRecordDTO = objectMapper.treeToValue(beanRechargeNode, CashRecordDTO.class); |
|
|
CashRecordDTO cashRecordDTO = objectMapper.treeToValue(beanRechargeNode, CashRecordDTO.class); |
|
|
page.setCashRecordDTO(cashRecordDTO); |
|
|
page.setCashRecordDTO(cashRecordDTO); |
|
|
|
|
|
Admin admin = (Admin) JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class); |
|
|
|
|
|
List<String> userMarkets = Arrays.asList(StringUtils.split(admin.getMarkets(), ",")); |
|
|
|
|
|
List<String> markets = marketService.getMarketIds(userMarkets); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取传入的市场列表 |
|
|
|
|
|
List<String> requestedMarkets = page.getCashRecordDTO() != null ? page.getCashRecordDTO().getMarkets() : null; |
|
|
|
|
|
|
|
|
|
|
|
// 权限校验逻辑 |
|
|
|
|
|
if (markets.contains("9") || markets.contains("9999")) { |
|
|
|
|
|
// 特权市场:9 或 9999,跳过权限校验,直接放行传入的 markets |
|
|
|
|
|
// 如果业务需要,也可以在这里做空值处理 |
|
|
|
|
|
if (page.getCashRecordDTO() != null) { |
|
|
|
|
|
// 保持 requestedMarkets 不变,原样接受 |
|
|
|
|
|
// 可选:如果 requestedMarkets 为 null,可设为默认值或保持 null |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 普通用户:必须校验权限 |
|
|
|
|
|
if (requestedMarkets == null || requestedMarkets.isEmpty()) { |
|
|
|
|
|
page.getCashRecordDTO().setMarkets(markets); |
|
|
|
|
|
} |
|
|
|
|
|
if (!markets.containsAll(requestedMarkets)) { |
|
|
|
|
|
String errorMsg = "无权限!请求的市场不在授权范围内。"; |
|
|
|
|
|
return Result.error(errorMsg); |
|
|
|
|
|
} |
|
|
|
|
|
// 校验通过,保持 requestedMarkets 不变 |
|
|
|
|
|
} |
|
|
// 从请求数据中获取语言设置,如果没有则使用默认值 |
|
|
// 从请求数据中获取语言设置,如果没有则使用默认值 |
|
|
String lang = "zh_CN"; |
|
|
String lang = "zh_CN"; |
|
|
JsonNode langNode = requestDataNode.path("lang"); |
|
|
JsonNode langNode = requestDataNode.path("lang"); |
|
|
@ -397,8 +430,36 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
JsonNode rootNode = objectMapper.readTree(message); |
|
|
JsonNode rootNode = objectMapper.readTree(message); |
|
|
JsonNode requestDataNode = rootNode.path("requestData"); |
|
|
JsonNode requestDataNode = rootNode.path("requestData"); |
|
|
JsonNode beanRechargeNode = requestDataNode.path("fundsDTO"); |
|
|
JsonNode beanRechargeNode = requestDataNode.path("fundsDTO"); |
|
|
|
|
|
String token = rootNode.path("token").asText(); |
|
|
FundsDTO fundsDTO = objectMapper.treeToValue(beanRechargeNode, FundsDTO.class); |
|
|
FundsDTO fundsDTO = objectMapper.treeToValue(beanRechargeNode, FundsDTO.class); |
|
|
page.setFundsDTO(fundsDTO); |
|
|
page.setFundsDTO(fundsDTO); |
|
|
|
|
|
Admin admin = (Admin) JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class); |
|
|
|
|
|
List<String> userMarkets = Arrays.asList(StringUtils.split(admin.getMarkets(), ",")); |
|
|
|
|
|
List<String> markets = marketService.getMarketIds(userMarkets); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取传入的市场列表 |
|
|
|
|
|
List<String> requestedMarkets = page.getFundsDTO() != null ? page.getFundsDTO().getMarkets() : null; |
|
|
|
|
|
|
|
|
|
|
|
// 权限校验逻辑 |
|
|
|
|
|
if (markets.contains("9") || markets.contains("9999")) { |
|
|
|
|
|
// 特权市场:9 或 9999,跳过权限校验,直接放行传入的 markets |
|
|
|
|
|
// 如果业务需要,也可以在这里做空值处理 |
|
|
|
|
|
if (page.getFundsDTO() != null) { |
|
|
|
|
|
// 保持 requestedMarkets 不变,原样接受 |
|
|
|
|
|
// 可选:如果 requestedMarkets 为 null,可设为默认值或保持 null |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 普通用户:必须校验权限 |
|
|
|
|
|
if (requestedMarkets == null || requestedMarkets.isEmpty()) { |
|
|
|
|
|
page.getFundsDTO().setMarkets(markets); |
|
|
|
|
|
} |
|
|
|
|
|
if (!markets.containsAll(requestedMarkets)) { |
|
|
|
|
|
String errorMsg = "无权限!请求的市场不在授权范围内。"; |
|
|
|
|
|
return Result.error(errorMsg); |
|
|
|
|
|
} |
|
|
|
|
|
// 校验通过,保持 requestedMarkets 不变 |
|
|
|
|
|
} |
|
|
// 从请求数据中获取语言设置,如果没有则使用默认值 |
|
|
// 从请求数据中获取语言设置,如果没有则使用默认值 |
|
|
String lang = "zh_CN"; |
|
|
String lang = "zh_CN"; |
|
|
JsonNode langNode = requestDataNode.path("lang"); |
|
|
JsonNode langNode = requestDataNode.path("lang"); |
|
|
@ -419,12 +480,12 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
try { |
|
|
try { |
|
|
JsonNode rootNode = objectMapper.readTree(message); |
|
|
JsonNode rootNode = objectMapper.readTree(message); |
|
|
JsonNode requestDataNode = rootNode.path("requestData"); |
|
|
JsonNode requestDataNode = rootNode.path("requestData"); |
|
|
JsonNode beanRechargeNode = requestDataNode.path("performanceDTO"); |
|
|
|
|
|
PerformanceDTO performanceDTO = objectMapper.treeToValue(beanRechargeNode, PerformanceDTO.class); |
|
|
|
|
|
|
|
|
JsonNode performanceDTONode = requestDataNode.path("performanceDTO"); |
|
|
|
|
|
PerformanceDTO performanceDTO = objectMapper.treeToValue(performanceDTONode, PerformanceDTO.class); |
|
|
page.setPerformanceDTO(performanceDTO); |
|
|
page.setPerformanceDTO(performanceDTO); |
|
|
// 从请求数据中获取语言设置,如果没有则使用默认值 |
|
|
|
|
|
|
|
|
// 从请求数据中获取语言设置 |
|
|
String lang = "zh_CN"; |
|
|
String lang = "zh_CN"; |
|
|
JsonNode langNode = requestDataNode.path("lang"); |
|
|
|
|
|
|
|
|
JsonNode langNode = rootNode.path("lang"); |
|
|
if (langNode != null && !langNode.asText().isEmpty()) { |
|
|
if (langNode != null && !langNode.asText().isEmpty()) { |
|
|
lang = langNode.asText(); |
|
|
lang = langNode.asText(); |
|
|
} |
|
|
} |
|
|
@ -852,6 +913,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
|
|
|
|
|
|
// 添加铁粉用户翻译支持 |
|
|
// 添加铁粉用户翻译支持 |
|
|
if ("fanUser".equals(exportType) && list.get(0) instanceof BeanConsumeFan) { |
|
|
if ("fanUser".equals(exportType) && list.get(0) instanceof BeanConsumeFan) { |
|
|
|
|
|
fillUserMemberStatusDescriptions((List<BeanConsumeFan>) list); |
|
|
translateBeanConsumeFanList((List<BeanConsumeFan>) list, lang); |
|
|
translateBeanConsumeFanList((List<BeanConsumeFan>) list, lang); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -874,6 +936,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
|
|
|
|
|
|
// 添加财务退款翻译支持 |
|
|
// 添加财务退款翻译支持 |
|
|
if ("financeUser".equals(exportType) && list.get(0) instanceof CashRecordDTO) { |
|
|
if ("financeUser".equals(exportType) && list.get(0) instanceof CashRecordDTO) { |
|
|
|
|
|
fillRechargeUserIsRefund((List<CashRecordDTO>) list); |
|
|
translateCashRecordDTOList((List<CashRecordDTO>) list, lang); |
|
|
translateCashRecordDTOList((List<CashRecordDTO>) list, lang); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -893,7 +956,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 添加资金流水翻译支持 |
|
|
// 添加资金流水翻译支持 |
|
|
if ("fundsUser".equals(exportType) && list.get(0) instanceof FundsDTO) { |
|
|
|
|
|
|
|
|
if ("fundUser".equals(exportType) && list.get(0) instanceof FundsDTO) { |
|
|
fillUserStatusDescriptions((List<FundsDTO>) list); |
|
|
fillUserStatusDescriptions((List<FundsDTO>) list); |
|
|
translateFundsList((List<FundsDTO>) list, lang); |
|
|
translateFundsList((List<FundsDTO>) list, lang); |
|
|
} |
|
|
} |
|
|
@ -1047,7 +1110,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
case "cashUser": |
|
|
case "cashUser": |
|
|
return CashCollection.class; |
|
|
return CashCollection.class; |
|
|
case "performanceUser": |
|
|
case "performanceUser": |
|
|
return PerformanceDTO.class; |
|
|
|
|
|
|
|
|
return PerformanceVO.class; |
|
|
case "fundUser": |
|
|
case "fundUser": |
|
|
return FundsDTO.class; |
|
|
return FundsDTO.class; |
|
|
default: |
|
|
default: |
|
|
@ -1056,6 +1119,31 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
* 填充用户会员的状态描述 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void fillUserMemberStatusDescriptions(List<BeanConsumeFan> fans) { |
|
|
|
|
|
if (fans != null && !fans.isEmpty()) { |
|
|
|
|
|
for (BeanConsumeFan fan : fans) { |
|
|
|
|
|
if (fan.getType() != null) { |
|
|
|
|
|
fan.setTypeDesc(fanTypeToString(fan.getType())); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 将会员类型数字转换为中文描述 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String fanTypeToString(Integer type) { |
|
|
|
|
|
if (type == null) return ""; |
|
|
|
|
|
switch (type) { |
|
|
|
|
|
case 7: return "单次付费"; |
|
|
|
|
|
case 8: return "连续包月"; |
|
|
|
|
|
default: return "其他"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
* 填充用户数据的状态描述 |
|
|
* 填充用户数据的状态描述 |
|
|
*/ |
|
|
*/ |
|
|
private void fillUserStatusDescriptions(List<FundsDTO> funds) { |
|
|
private void fillUserStatusDescriptions(List<FundsDTO> funds) { |
|
|
@ -1067,6 +1155,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 将类型数字转换为中文描述 |
|
|
* 将类型数字转换为中文描述 |
|
|
*/ |
|
|
*/ |
|
|
@ -1106,6 +1195,20 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|
|
|
* 填充财务退款用户数据的退款方式描述 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void fillRechargeUserIsRefund(List<CashRecordDTO> cashRecords) { |
|
|
|
|
|
if (cashRecords != null && !cashRecords.isEmpty()) { |
|
|
|
|
|
for (CashRecordDTO cashRecord : cashRecords) { |
|
|
|
|
|
if (cashRecord.getRefundModel() != null) { |
|
|
|
|
|
String modelDesc = convertRefundModelToString(cashRecord.getRefundModel()); |
|
|
|
|
|
cashRecord.setRefundModelDesc(modelDesc); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
* 填充退款用户数据的退款方式描述 |
|
|
* 填充退款用户数据的退款方式描述 |
|
|
*/ |
|
|
*/ |
|
|
private void fillRefundUserModelDescriptions(List<RefundUser> refundUsers) { |
|
|
private void fillRefundUserModelDescriptions(List<RefundUser> refundUsers) { |
|
|
@ -1179,7 +1282,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
private String convertIsRefundToString(Integer isRefund) { |
|
|
private String convertIsRefundToString(Integer isRefund) { |
|
|
if (isRefund == null) return ""; |
|
|
if (isRefund == null) return ""; |
|
|
switch (isRefund) { |
|
|
switch (isRefund) { |
|
|
case 0: return "未退款"; |
|
|
|
|
|
|
|
|
case 0: return "正常"; |
|
|
case 1: return "已退款"; |
|
|
case 1: return "已退款"; |
|
|
default: return "未知状态"; |
|
|
default: return "未知状态"; |
|
|
} |
|
|
} |
|
|
@ -1224,6 +1327,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 将充值平台数字转换为中文描述 |
|
|
* 将充值平台数字转换为中文描述 |
|
|
*/ |
|
|
*/ |
|
|
@ -1257,10 +1361,38 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
if (type == null) return ""; |
|
|
if (type == null) return ""; |
|
|
switch (type) { |
|
|
switch (type) { |
|
|
case 9, 10: return "打赏"; |
|
|
case 9, 10: return "打赏"; |
|
|
case 11: return "付费"; |
|
|
|
|
|
default: return "未知"; |
|
|
|
|
|
|
|
|
case 11: return "付费购买"; |
|
|
|
|
|
default: return "其他"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据状态值获取状态描述 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String getStatusDescription(Integer status) { |
|
|
|
|
|
if (status == null) return ""; |
|
|
|
|
|
|
|
|
|
|
|
switch (status) { |
|
|
|
|
|
case 0: return "线下财务待审核"; |
|
|
|
|
|
case 1: return "线下财务审核通过待填手续费"; |
|
|
|
|
|
case 2: return "线下财务审核驳回"; |
|
|
|
|
|
case 3: return "link线上财务复核待填手续费"; |
|
|
|
|
|
case 4: return "收款流程全部结束"; |
|
|
|
|
|
case 5: return "手动撤回待编辑提交"; |
|
|
|
|
|
case 6: return "退款"; |
|
|
|
|
|
case 10: return "地区财务待审核"; |
|
|
|
|
|
case 11: return "地区财务手动撤回待编辑提交"; |
|
|
|
|
|
case 12: return "地区财务驳回"; |
|
|
|
|
|
case 20: return "地区负责人待审核"; |
|
|
|
|
|
case 22: return "地区负责人驳回"; |
|
|
|
|
|
case 30: return "总部财务待审核"; |
|
|
|
|
|
case 32: return "总部财务驳回"; |
|
|
|
|
|
case 40: return "执行人待处理"; |
|
|
|
|
|
case 41: return "执行人已处理,退款结束"; |
|
|
|
|
|
default: return "未知状态(" + status + ")"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 各种实体类的翻译方法 |
|
|
// 各种实体类的翻译方法 |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -1448,8 +1580,8 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 翻译会员类型 |
|
|
// 翻译会员类型 |
|
|
if (item.getType() != null && !item.getType().isEmpty()) { |
|
|
|
|
|
item.setType(languageTranslationUtil.translate(item.getType(), lang)); |
|
|
|
|
|
|
|
|
if (item.getTypeDesc() != null && !item.getTypeDesc().isEmpty()) { |
|
|
|
|
|
item.setTypeDesc(languageTranslationUtil.translate(item.getTypeDesc(), lang)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -1555,6 +1687,28 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
if (item.getRefundRemark() != null && !item.getRefundRemark().isEmpty()) { |
|
|
if (item.getRefundRemark() != null && !item.getRefundRemark().isEmpty()) { |
|
|
item.setRefundRemark(languageTranslationUtil.translate(item.getRefundRemark(), lang)); |
|
|
item.setRefundRemark(languageTranslationUtil.translate(item.getRefundRemark(), lang)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 翻译退款方式 |
|
|
|
|
|
if (item.getRefundModelDesc() != null && !item.getRefundModelDesc().isEmpty()) { |
|
|
|
|
|
item.setRefundModelDesc(languageTranslationUtil.translate(item.getRefundModelDesc(), lang)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 翻译所属地区名称 |
|
|
|
|
|
if (item.getMarketName() != null && !item.getMarketName().isEmpty()) { |
|
|
|
|
|
item.setMarketName(languageTranslationUtil.translate(item.getMarketName(), lang)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 翻译订单状态(首先获取状态的中文描述,然后进行多语言翻译) |
|
|
|
|
|
if (item.getStatus() != null) { |
|
|
|
|
|
String statusDesc = getStatusDescription(item.getStatus()); |
|
|
|
|
|
String translatedStatus = languageTranslationUtil.translate(statusDesc, lang); |
|
|
|
|
|
item.setStatusDesc(translatedStatus); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 翻译商品单位 |
|
|
|
|
|
if (item.getNumUnit() != null && !item.getNumUnit().isEmpty()) { |
|
|
|
|
|
item.setNumUnit(languageTranslationUtil.translate(item.getNumUnit(), lang)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|