Browse Source

12月3日现金管理多语言配置,优化退款方式导出Excel(2)

milestone-20251125-多语言
wangguorui 1 month ago
parent
commit
9b9ffd55ac
  1. 45
      src/main/java/com/example/demo/serviceImpl/coin/ExportExcelServiceImpl.java

45
src/main/java/com/example/demo/serviceImpl/coin/ExportExcelServiceImpl.java

@ -32,8 +32,6 @@ import com.example.demo.serviceImpl.cash.CashRefundServiceImpl;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.example.demo.service.coin.AiEmotionService; import com.example.demo.service.coin.AiEmotionService;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -57,7 +55,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.function.Function; import java.util.function.Function;
@Service @Service
@Slf4j @Slf4j
public class ExportExcelServiceImpl implements ExportExcelService { public class ExportExcelServiceImpl implements ExportExcelService {
@ -93,8 +90,6 @@ public class ExportExcelServiceImpl implements ExportExcelService {
@Autowired @Autowired
private ExportMapper exportMapper; private ExportMapper exportMapper;
@Transactional @Transactional
@Override @Override
public Exception handleExcelExportData(String message) throws Exception { public Exception handleExcelExportData(String message) throws Exception {
@ -150,6 +145,7 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} }
}); });
} }
@Transactional @Transactional
@Override @Override
public Exception consumeExcel(String message) throws Exception { public Exception consumeExcel(String message) throws Exception {
@ -241,6 +237,7 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} }
}); });
} }
@Override @Override
public Exception BeanExcel(String message) throws Exception { public Exception BeanExcel(String message) throws Exception {
return exportExcelGeneric(message, "beanUser", page -> { return exportExcelGeneric(message, "beanUser", page -> {
@ -256,6 +253,7 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} }
}); });
} }
@Override @Override
public Exception OnlineExcel(String message) throws Exception { public Exception OnlineExcel(String message) throws Exception {
return exportExcelGeneric(message, "onlineUser", page -> { return exportExcelGeneric(message, "onlineUser", page -> {
@ -311,8 +309,6 @@ public class ExportExcelServiceImpl implements ExportExcelService {
return list; return list;
} }
/** /**
* 验证导出记录 * 验证导出记录
*/ */
@ -400,6 +396,11 @@ public class ExportExcelServiceImpl implements ExportExcelService {
fillGoldDetailTypeDescriptions((List<GoldDetail>) list); fillGoldDetailTypeDescriptions((List<GoldDetail>) list);
} }
// 添加退款方式转换逻辑
if ("refundUser".equals(exportType) && list.get(0) instanceof RefundUser) {
fillRefundUserModelDescriptions((List<RefundUser>) list);
}
excelWriter.write(list, writeSheet); excelWriter.write(list, writeSheet);
page.setPageNum(page.getPageNum() + 1); page.setPageNum(page.getPageNum() + 1);
totalCount += list.size(); totalCount += list.size();
@ -412,7 +413,6 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} }
} }
// 7. 完成Excel写入 // 7. 完成Excel写入
if (excelWriter != null) { if (excelWriter != null) {
excelWriter.finish(); excelWriter.finish();
@ -523,9 +523,6 @@ public class ExportExcelServiceImpl implements ExportExcelService {
return null; return null;
} }
private Class<?> getExportClass(String exportType) { private Class<?> getExportClass(String exportType) {
switch (exportType) { switch (exportType) {
case "goldDetail": case "goldDetail":
@ -556,6 +553,7 @@ public class ExportExcelServiceImpl implements ExportExcelService {
throw new IllegalArgumentException("不支持的导出类型: " + exportType); throw new IllegalArgumentException("不支持的导出类型: " + exportType);
} }
} }
/** /**
* 填充金币明细数据的类型描述 * 填充金币明细数据的类型描述
*/ */
@ -582,4 +580,29 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} }
} }
/**
* 填充退款用户数据的退款方式描述
*/
private void fillRefundUserModelDescriptions(List<RefundUser> refundUsers) {
if (refundUsers != null && !refundUsers.isEmpty()) {
for (RefundUser user : refundUsers) {
if (user.getRefundModel() != null) {
String modelDesc = convertRefundModelToString(user.getRefundModel());
user.setRefundModelDesc(modelDesc);
}
}
}
}
/**
* 将退款模型数字转换为中文描述
*/
private String convertRefundModelToString(Byte refundModel) {
if (refundModel == null) return "";
switch (refundModel) {
case 0: return "全部退款";
case 1: return "部分退款";
default: return "未知退款方式";
}
}
} }
Loading…
Cancel
Save